Posted by: prajapatinilesh | September 17, 2007

Password and confirm pass

<HTML>
<HEAD>
<TITLE>Verify Notify Example</TITLE>
<!– Load the verifynotify javascript code –>
<SCRIPT TYPE=”text/javascript” src=”verifynotify.js”></SCRIPT>
</HEAD>
<BODY>
<H1></H1>
<FORM NAME=”password_form” ACTION=”” METHOD=”POST”>
Password:<BR>
<INPUT TYPE=password NAME=password1 onKeyUp=”verify.check()”>
<P>
Re-enter Password:<BR>
<INPUT TYPE=password NAME=password2 onKeyUp=”verify.check()”>
<P>
<!– Display a message if the passwords match or don’t match –>
<DIV ID=”password_result”>&nbsp;</DIV>
</FORM>
<SCRIPT TYPE=”text/javascript”>
<!–
verify = new verifynotify();
verify.field1 = document.password_form.password1;
verify.field2 = document.password_form.password2;
verify.result_id = “password_result”;
verify.match_html = “<SPAN STYLE=\”color:blue\”>Thank you, your passwords match!<\/SPAN>”;
verify.nomatch_html = “<SPAN STYLE=\”color:red\”>Please make sure your passwords match.<\/SPAN>”;
// Update the result message
verify.check();
// –>
</SCRIPT>
</BODY>
</HTML>

**************************************************

//file: verifynotify.js

function verifynotify(field1, field2, result_id, match_html, nomatch_html) {
this.field1 = field1;
this.field2 = field2;
this.result_id = result_id;
this.match_html = match_html;
this.nomatch_html = nomatch_html;
this.check = function() {
// Make sure we don’t cause an error
// for browsers that do not support getElementById
if (!this.result_id) { return false; }
if (!document.getElementById){ return false; }
r = document.getElementById(this.result_id);
if (!r){ return false; }
if (this.field1.value != “” && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
} else {
r.innerHTML = this.nomatch_html;
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: