JavaScript function to validate an integer value

Posted by Psyche on Stack Overflow See other posts from Stack Overflow or by Psyche
Published on 2010-06-06T20:07:43Z Indexed on 2010/06/06 20:12 UTC
Read the original article Hit count: 140

Filed under:

Hello,

I'm building a shopping cart and I would like to use a JavaScript function to validate user input when entering the quantity value in the quantity text input. I would like to allow the entering of integer values only (no floats, no other characters).

I know that I can apply this function using onKeyUp event and also I found isNaN() function, but it returns true even for floats (which is not ok).

Can you guys help me out with this one?

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript