in reply to Validating specific numeric input
Try this: if (/^-?\d+\.\d*$/)Incidentally, you could combine the two tests into one regexp, but it looks like you want to keep the distinction between those with decimal points and those without. If not, you could do this: if (/^-?\d+(\.\d*)?$/) Note that this second one will capture the fractional part, if any. If that's undesirable, do: if (/^-?\d+(?:\.\d*)?$/) HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Validating specific numeric input
by jlongino (Parson) on May 02, 2002 at 19:08 UTC |