Link to home
Start Free TrialLog in
Avatar of zneria
zneria

asked on

Number validation vbscript

I've got an old school web page that was built for us many years back. It has an insert page and a submit page that validates some fields and then fowards them to our sql server. Currently it validates if the field is filled in with text or numeric, but I need it to validate for numerics only. Below is the actual text where the validation occurs. Any help would be appreciated.

Dim annual_quantity_n
annual_quantity_n = Replace(Request("annual_quantity_n"),"'","''")
Validate annual_quantity_n,"Annual Quantity"

Zach
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try use IsNumeric function to check whether a value is numeric or not, like:

...
if isnumeric(yourValue) = false then
    msgbox "The value is not numeric"
    exit sub
end if
..
if is in ASP, something similar:

...
if isnumeric(yourValue) = false then
    response.write "The value is not numeric"
  '...
end if
..
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Normally one would write..

that's depends on how a developer write the syntax, which basically both working fine...
Avatar of jitganguly
jitganguly

If its user input you should have clent side Javascript validation

http://www.google.com/search?q=numbers+only++with+isNaN&hl=en&safe=active
Avatar of zneria

ASKER

Sybe I'll go ahead and try this out on the submit page. Jitganguly I'm aware of the javascript however I didn't build these pages and I need it to be vbscript on the submit page, not the input page. Thanks for the 411 though.
>>Thanks for the 411 though.
:-). It was 555 1212 :-)

Good luck
Avatar of zneria

ASKER

Sybe,
The code worked like a charm. Can't thank you enough man =)

Zach