>>>Hi everybody,
>>>
>>>I have a JavaScript to ValidateDate (called ValidateDate). This script is attributed to Einar Kvandahl. I need a similar script to validate number (should only allow integer positive numbers). Is there something built in?
>>>
>>>Thanks in advance.
>>
>>I hit up google and found
http://acmesoffware.com/acme/ExamplesJS/jsExm_ValidateInteger.asp. Please let me know if you find one that works well because I'm sure I will eventually need one.
>
>I can not yet make it work. Here is the page and the function
>
>
http://forums.asp.net/p/1417609/3131496.aspx#3131496I found a sample of something I have done. I haven't looked internally at what it's actually doing as I was told to just use it, but it seems to work. It actually won't allow anything other than a number in a textbox.
Textbox control (Note onKeyPress):
<asp:TextBox CssClass="requiredField" ID="YearsBillingTextBox" runat="server" Width="50px" MaxLength="3"
onKeyPress="event.returnValue=isNumberKey(event)" />
Javascript function:
//Only allow numeric input
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}