in reply to Validating Numbers in CGI Script?
The same could be achieved with $invalue =~ /^\d+$/ but as we all know...my $invalue = param( 'INVALUE' ); if ( defined $invalue ) { if ( $invalue =~ /\D/ ) { $result = "$invalue is *not* a Number@" } else { $result = "$invalue is a number."; } } else { $result = "Enter a value to test." }
hope this helps$less->{'characters'}->{'typed'} == `"time in the pub" | more`; # :-D
Update: _doh_!! just re-read your post and realised I would have to quickly whip up a regex to allow "-"s and a possible "." so here it is...
oh, and for people who like to leave off a leading 0 on decimals > -1 but < 1.../^(?:-)?\d+(?:\.\d+)?$/
I would be interested in an optimisation of this if anyone can do better./^(?:-)?(?:\d+(?:\.\d+)?|\.\d+)$/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Validating Numbers in CGI Script?
by japhy (Canon) on May 10, 2001 at 18:58 UTC | |
by dha (Acolyte) on May 11, 2001 at 03:08 UTC | |
by japhy (Canon) on May 11, 2001 at 03:51 UTC | |
by tilly (Archbishop) on May 11, 2001 at 05:56 UTC | |
by larryk (Friar) on May 10, 2001 at 19:27 UTC | |
by japhy (Canon) on May 10, 2001 at 19:42 UTC | |
by buckaduck (Chaplain) on May 10, 2001 at 21:24 UTC | |
by lestrrat (Deacon) on May 10, 2001 at 21:50 UTC |