Hallo friends,
Could you please help me to validate a textbox. I would like it to accept only numbers from "0 to 9" and Character " : ".
Thanks for helping.
Bonhomme Sanon
Please refer below.
HTML
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript"> function onlyNumbersWithColon(e) { var charCode; if (e.keyCode > 0) { charCode = e.which || e.keyCode; } else if (typeof (e.charCode) != "undefined") { charCode = e.which || e.keyCode; } if (charCode == 58) return true if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </script> </head> <body> <form id="form1" runat="server"> <div> <input type="text" name="name" onkeypress="return onlyNumbersWithColon(event);" /> </div> </form> </body> </html>
Demo
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.