|
function test(obj,msg)
{
var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
if (regex.test(obj.value))
{
return true;
}
else
{
alert(msg);
obj.focus();
return false;
}
}
function ReqField1Validator()
{
if (document.getElementById('txtName').value == ' ') /*txtName is the
name of field (server side control )you want to validate*/
{
alert('Full Name cannot be Empty')
return false;
}
/* here you can add more field you want to validate*/
if(!test(document.getElementById('txtLogin'),"Please Enter Valid Email
Address"))
return false;
return true ;
}
/* Write this code in this page Load Event -- where btnSubmit is the
name of Button on which you want to call the function. */
this.btnSubmit.Attributes.Add("onclick","return ReqField1Validator()");
|