Friday, August 14, 2009

Javascript to allow user to enter only numeric value.


function AllowNumericValue(myevent)
{
var charVal = (myevent.which) ? myevent.which : myevent.keyCode
if (charVal > 31 && (charVal < 48 || charVal > 57))
{
return false;
}
return true;

}


input type="text" id="Text2" onkeypress="return AllowNumericCharacters(event)"

No comments: