Wednesday, June 25, 2008

Javascript validation-ASP.NET

function Murugesan()
{
var d=document.getElementById('TextBox1').value;
if(d=="")
{
alert("cant be blank");
return false;
}
else
{
return true;
}

}
Place above source code on source code window between head tag.Here I simply check the TextBox,wheather it has value or blank.

On code behind file,
Register the control which has to be call this javascript.
Button1.Attributes.Add("onclick", "return Murugesan()");