• Post Reply Bookmark Topic Watch Topic
  • New Topic

validating that field has a number  RSS feed

 
Lauren Pender
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to validate in javascript that the text entered in a field is a number.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lauren
use this test
if (isNaN(document.formName.fieldName.value))
if it returns true then the value in the field is not a number.
hope that helps
Dave
[This message has been edited by Dave Vick (edited June 19, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!