menu

Saturday, June 26, 2010

Required text field validator using javascript

Write this javascript code inside to "HEAD" tag of .aspx file

function FormValidator(theForm)
{
if (theForm.TextBox1.value == "")
{
alert("You must enter somthing");
theForm.TextBox1.focus();
return (false);
}
}

call this function in form's onsubmit event

form id="form1" runat="server" onsubmit="return FormValidator(this)"

No comments:

Post a Comment