• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

ASP - quick check for positive integer value

Hi

I'm validating the contents of a form and need to check that one of the values is a positive integer. Is there an easy way to do this? I can check that it's numeric and that it's positive, but I'm a bit stumped on the integer bit. I basically need a function which will reject all non-integer values.

Thanks :-)


0
Nicola-H
Asked:
Nicola-H
  • 3
1 Solution
 
lluthienCommented:
Do you need a vbscript (asp) check or a clientside (javascript) check?
0
 
lluthienCommented:
easiest way is probably to check for a decimalseparator in the string.

0
 
TimCotteeCommented:
Hi Nicola-H,

Or simply check

If n = int(n) Then
    'It is an integer
...

Tim Cottee
0
 
lluthienCommented:
tim's entry works, but it does assume you check serverside.
0
 
Nicola-HAuthor Commented:
Nice and simple - thanks Tim. It was server side code I needed, and unfortunately checking for decimal separators would not work in circumstamces where the idiot user entered bizarre strings of text. Some of the people who use these forms enter all manner of random carp.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now