Textbox Validations using javascript
Hi friends i need to enter only numeric in textboxes.i tried this coed but it is not working.Can u mention wat is wrong in this code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT language=Javascript>
function allownumbers(event)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</SCRIPT>
Code-Behind File
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onkeypress", "javascript:return allownumbers(event);");
}
|