For Validating the Year Value Using Javascript

Chikul
Posted by Chikul under JavaScript category on | Views : 1615
//Purpose : For Validating the Year Value
function ValidateYear(obj)
{
if (obj.length !=0)
{
var text = /^[0-9]+$/;
if ((document.getElementById(obj.id).value!="")&&(!text.test(document.getElementById(obj.id).value)))
{
alert("Please Enter Numeric Values Only");
obj.focus();
obj.select();
}
if (document.getElementById(obj.id).value.length>4)
{
alert("Year is not proper. Please check");
obj.focus();
obj.select();
}
}
}

Comments or Responses

Login to post response