/    Sign up×
Community /Pin to ProfileBookmark

Compare Username/Password:

What I’m trying to do is setup a username/password through a cookie. I have the cookie portion setup but i’m not sure how to do the password and username. I am trying to setup an “IF” statement that would comapre username.value and password.value from the cookie itself through a string.

Here is my code, I’m not sure where to start with this, could someone provide some insight?

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd“>

<html><head><title>Project 8-3</title></head>

<body>
<strong><center><p> Welcome to the most interesting website you have seen in years. Yes, I realize that this doesn’t do much,
but I don’t know a whole lot about Internet programming so just lay off and enter your username and password
and we will all get along. Oh, and don’t make me check whether you entered your password correctly cause that
makes even more work for the guy running this damn thing! Thanks and have a wonderful day.</p></Center></strong>

<center> <p> Make sure that you password is no longer than 16 characters, thanks!</p></center>

<FORM Action “”>
<center> Username: <input type =”text” name=”userName”> <br /></center>
<center> Password: <input type =”password” name=”passWord” maxlength =”16″><br /></center>

<center><input name=”submitButton” value=”Enter” ;=”” type=”button” onClick=”return ChckPassWrd();”></center>

</FORM>

<script type=”text/Javascript”>

<!–HIDE FROM INCOMPATIBLE BROWSERS

function ChckPassWrd(){
if (document.forms[0].userName.value != ” “)
{
window.alert (“You have not entered a username”);
document.forms[0].userName.focus(); //set the cursor back to username text
return true;
} // trying to set this so once text is entered it goes to password

else { (document.forms[0].passWord != ” “)
window.alert (“You have not entered a password”);
return false;
document.forms[0].passWord.focus(); //set the cursor back to password field

}

}

function setcookie(){
var expiresDate = new Date ();

expiresdate.setfullyear(expiresDate.getfullyear() +1);
document.cookie = encodeURI(“userName=” + document.forms[0].userName.value) + “; expires=”
+expiresDate.toUTCString();
document.cookie = encodeURI(“passWord=” + document.forms[0].passWord.value) + “; expires=”
+expiresDate.toUTCString();

}

//STOP HIDING FROM INCOMPATIBLE BROWSERS –>
</script>

</body>

</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @duff2481 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...