Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Validating a input field which contains only decimal numbers


Message #1 by Rich <ejbquestions@y...> on Sat, 19 Jan 2002 12:00:47 -0800 (PST)
call this on the KeyPress of whatever you want...



function numbersonly(){
if
((isNaN(String.fromCharCode(event.keyCode)))&&(event.keyCode!=8)||(event.shi
ftKey))
event.returnValue=false
}

-----Original Message-----
From: Christine Sun [mailto:Christine_Sun@c...]
Sent: Saturday, January 19, 2002 5:10 PM
To: javascript
Subject: [javascript] RE: Validating a input field which contains only
dec imal numbers


Can you use asp.net?  it has built-in validators.
You can probably use RangeValidator, something like:
<asp:RangeValidator ControlToValidate="txtQC_Audit" 
                                Type=float
                                MinimumValue=0.0
                                MaximumValue=999999.9999 
                                Runat=server 
                                ID=RangeValidator_txtQC_Audit
                                Display="Dynamic">
                                 VALUE SHOULD BE BETWEEN 0-100
            </asp:RangeValidator>

-----Original Message-----
From: Rich [mailto:ejbquestions@y...]
Sent: Saturday, January 19, 2002 12:01 PM
To: javascript
Subject: [javascript] Validating a input field which contains only
decimal numbers


Hi, 
   I have a input text element which can contain only
decimal numbers.
e.g should contain only numbers between 0.0000 and
999999.9999.
I want to be able to validate the input on the
KeyPress event and  disable the keypressed if its not
a number or if the digits after the decimal is greater
that say 4. How do I do this?

Thanks,
Rich

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/



  Return to Index