Disallowing to Enter Numeric values using Javascript.

vishalneeraj-24503
Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 1215
<script type = "text/javascript">
function Is_Numeric(event)
{
var kCode = event.keyCode || event.charCode; //for cross browser check

//FF and Safari use e.charCode, while IE use e.keyCode that returns the ASCII value
if ((kCode > 57 || kCode < 48) && (kCode != 46 && kCode != 45))
{
//code for IE
if (window.ActiveXObject)
{
event.keyCode = 0
return false;
}
else
{
event.charCode = 0
}
}
}
</script>

<asp:TextBox ID = "txt1" runat ="server"
onkeypress = "return Is_Numeric(event);"></asp:TextBox>

Comments or Responses

Login to post response