...

View Full Version : validate two password fields



urgido
08-28-2006, 11:09 PM
I want to validate two input text fields.

If the passwords are equals it show an image called OK.gif (I suppose this is with document.write) but if passwords not are equals it show an image called NOT.gif.


Regards

Anthony2oo4
08-28-2006, 11:33 PM
not tested but should work:

<script type="text/javascript">
<!--
/*<![CDATA[*/
function User() {
gifyes = "yes.gif"; //Gif if yes
gifno = "no.gif"; //Gif if no

pass1 = document.validate.pass1.value;
pass2 = document.validate.pass2.value;

if (pass1 == pass2) {
handle = "<img border=\"0\" src=\""+gifyes+"\">";
} else {
handle = "<img border=\"0\" src=\""+gifno+"\">";
}
document.write(handle);
}
/*]]>*/
// -->
</script>
<form method="POST" action="" onsubmit="check();" name="validate">
<p><input type="password" name="pass1" size="20"></p>
<p><input type="password" name="pass2" size="20"></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

urgido
08-29-2006, 12:15 AM
not work :S

I put all code into <body></body> tags

urgido
08-29-2006, 12:31 AM
function verif(){
if (signupform.reg_pass.value==signupform.reg_retype.value) {
document.write("<img src=ok.gif border=0>"); return true
} else {
document.write("<img src=not.gif border=0>"); return false
}
}

It works! but it show me the image in other page :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum