menu

Sunday, June 27, 2010

Password field validation (match) through javascript

Write this javascript code inside "HEAD" - "SCRIPT" tag

function chkPass()
{
if(form1.TextBox1.value.length < 5)
{
alert("Password must be of more than 5 and less char");
return (false);
}
else if(form1.TextBox1.value != form1.TextBox2.value)
{
alert("Both Password are not the same");
return (false);
}
}

call this function in form's onsubmit event

form id="form1" runat="server" onsubmit="return chkPass()"

No comments:

Post a Comment