Restricting users to enter only numbers inside a text box แบบที่ 2

วิธีเขียน JavaScript กำหนดให้ User ป้อนข้อมูลที่เป็น ตัวเลขลงใน TextBox เท่านั้น (แบบที่ 2)

<HTML>
<HEAD>
<SCRIPT language=Javascript>
<!–
function isNumberKey(evt)

{

var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;

}
//–>
</SCRIPT>
</HEAD>
<BODY>
<INPUT id=”txtChar” onkeypress=”return isNumberKey(event)” type=”text” name=”txtChar”>
</BODY>
</HTML>

1 Comment

Other Links to this Post

  1. blog.monthon.com » Restricting users to enter only numbers inside a text box — 18/09/2008 @ 22:54

RSS feed for comments on this post. TrackBack URI

Leave a comment

Security Code: