Tuesday, April 24, 2007

password and email validations Java script

<script language="javascript">

function CheckSignup_new(frm)

{


if(frm.new_member_id.value.length == 0 || frm.new_member_id.value=='USER NAME')

{

alert("Please enter Username!");

frm.new_member_id.focus();

return false;

}

if(frm.password.value.length == 0 || frm.password.value=='PASSWORD')

{

alert("Please enter Password!");

frm.password.focus();

return false;

}

if(frm.repassword.value.length == 0 || frm.repassword.value=='PASSWORD')

{

alert("Please enter Confirm Password!");

frm.repassword.focus();

return false;

}





var re = /^(([^<>()[\]\\.,;:\s@\"]+
(\.[^<>()[\]\\.,;:\s@\"]+)*)|
(\".+\"))@
((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])
|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/





if (!frm.email.value.match(re))

{

alert("Please enter valid Email!");

frm.email.focus();

return false;

}



if(frm.email.value.length == 0 || frm.email.value=='EMAIL')

{

alert("Please enter your email!");

frm.email.focus();

return false;

}







if(frm.password.value !=frm.repassword.value)

{

alert("Cofirm password is wrong\n please retype?");

frm.repassword.focus();

return false;

}

return true;

}

</script>


this submit button within the form tag...


<input type="submit" name="signup" value="signup" onClick='return CheckSignup_new(this.form);'>

No comments: