javascript - how to valid only digit in textbox in firefox? -
i have problem valid digit in textbox in ie 9 , firefox 4 & 5, 1 know ? try previous question's answer still face problem, want use enter digit in textbox, use asp.net code language.
as far i've understood want allow numeric characters in text field , return other characters if not numeric. so, may go through this
step1. create javascript function
<script language="text/javascript"> function onlynumbers(evt) { var e = window.event || evt; // trans-browser compatibility var charcode = e.which || e.keycode; if (charcode > 31 && (charcode < 48 || charcode > 57)) return false; return true; } </script>
step2. onkeypress call function this
if call javascript method on event first parameter passed event. ie need catch event window.event.
for more clear ideas can visit:- https://developer.mozilla.org/en/dom/event
Comments
Post a Comment