Posted by: prajapatinilesh | September 17, 2007

Password and confirm pass

<TITLE>Verify Notify Example</TITLE>
<!– Load the verifynotify javascript code –>
<SCRIPT TYPE=”text/javascript” src=”verifynotify.js”></SCRIPT>
<FORM NAME=”password_form” ACTION=”” METHOD=”POST”>
<INPUT TYPE=password NAME=password1 onKeyUp=”verify.check()”>
Re-enter Password:<BR>
<INPUT TYPE=password NAME=password2 onKeyUp=”verify.check()”>
<!– Display a message if the passwords match or don’t match –>
<DIV ID=”password_result”>&nbsp;</DIV>
<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
// –>


//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;


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s


%d bloggers like this: