Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validating if the input value is float??

 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ..... i want to make a validation for my input text..whether it is float or not...
How can i do it through javascript.

please help.

i tried doing something like this...




and my javascript function is..




but on my jsp page it gives error saying an object is expected..
please help ... although the alert staement in the function that is alert("float value is.."+floatValue); is getting printed fine
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*All* text input values are just that: text. You'd need to check against a regular expression, or maybe try converting it and checking for failure--but that may be error-prone.

Also, note that isFloat() is actually Number.isFloat(), not a standalone function.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic