Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: regular expressions


Message #1 by "Garrett Steed" <gmsteed@s...> on Wed, 23 Oct 2002 11:17:30 -0700
Not to long ago I sent a form validation example that looped through any
generic form and would check to see each form element was either positive,
had data in it, or was a number.  To check if the form elements was an
number I used this:

if(isNaN(parseInt(domLocation.elements[i].value))){do this thing}

this works as long as the data doesn't resemble hex code.  I had tried using
a regular expression like this:

var reDigit = /\d+$/;
if(domLocation.elements[i].value != reDigit){do this thing}

My question is this.  Can someone tell me the correct regular expression to
find out if the data in a form element is an int.  And how to format the
"if" statement for that.  I think I have tied everything but checking for
each alpha char.  Thanks

Garrett


  Return to Index