JavaScript method to validate the text field, the text field should be mandatory

Amatya
Posted by Amatya under JavaScript category on | Points: 40 | Views : 213
JavaScript method to validate the text field, the text field should be mandatory. If the text is empty then alert message will be popped Permit Type Cold Work field cannot be blank!

function Validate()
{
var txt_cold = document.getElementById("<%=txt_cold.ClientID%>");
if (txt_cold.value.length <= 0)
{
alert("Permit Type Cold Work field cannot be blank!");
document.getElementById("<%=txt_cold.ClientID%>").focus();
return (false);
}

}


Thanks
Amatya

Comments or Responses

Login to post response