Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Verification JS, PART 2

Status
Not open for further replies.

bdasp1

Technical User
Jan 9, 2002
11
0
0
US
Thanks to the help of RNK and StarWay, I am now using the following script to verify password entries. My next task is this. If the entries do not match, I would like for the 2 password fields to be cleared and the focus returned to the 1st field. Currently, the script checks the 2 values, and returns both an alert and the Focus to the 1st field. Can this be done? Thanks again!

html>
<head>
<title>
test
</title>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--
function validatePass(){
var frm = window.document.forms['register'];
if(frm.pass.value != frm.repass.value){
alert(&quot;Your passwords do not match\n&quot;+
&quot;please re-enter your password&quot;);
frm.pass.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<form name=&quot;register&quot;>
<p><input type=&quot;password&quot; name=&quot;pass&quot; onfocus=&quot;this.select();&quot; /></p>
<p><input type=&quot;password&quot; name=&quot;repass&quot; onblur=&quot;validatePass();&quot; onfocus=&quot;this.select();&quot;/></p>
</form>
</body>
</html>
 
Try this it should work...

function validatePass(){
var frm = window.document.forms['register'];
if(frm.pass.value != frm.repass.value){
alert(&quot;Your passwords do not match\n&quot;+
&quot;please re-enter your password&quot;);
document.register.pass.value=&quot;&quot;;
document.register.repass.value=&quot;&quot;;
frm.pass.focus();
return false;

Have Fun...

Sharky99 >:):O>
 
function validatePass() {
var frm = window.document.forms['register'];
if(frm.pass.value != frm.repass.value)
{
alert(&quot;Your passwords do not match\n&quot;+
&quot;please re-enter your password&quot;);
frm.repass.value=&quot;&quot;;
frm.pass.value=&quot;&quot;;
frm.pass.focus();
return false;
}
}
 
Thank you. If there's a problem that you guys can't solve, I haven't found it yet. Amazing!
 
When you find what you asked for, it would be cool if you mark it with a star that way we know for sure we've been helpful. ;-) (not talking just for me)

Thanks

Have Fun...

Sharky99 >:):O>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top