Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Data type/format of entry

Status
Not open for further replies.

endoflux

Technical User
Aug 6, 2001
227
US
I have an html form input which I need to test for a valid numeric entry. Currently, all other data validation is being done at the top of my form post page before the entries are submitted the the database (ASP). In one case, I'm using the subroutine below for an alpha-numeric entry which has a specific length anf format; maybe there's a variation that would allow me to specify only numeric format/datatype, but allow any length?

Function InputMask(Recnum)
Dim sln
Set sln = new RegExp

sln.IgnoreCase = false
sln.global = false
sln.Pattern = "^[0-9][A-Z][A-Z][A-Z][0-9][0-9]$"

InputMask = sln.Test(Recnum)
End Function

If Not InputMask(Recnum) Then Response.Redirect ReDir2
End If
 
sln.Pattern = "^\d+"

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
oops:

sln.Pattern = "^\d+$"

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Why not simply the IsNumeric function ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
THat would work as long as decimal entries are considered valid in the context of the application. From the original post, I could see it going either way.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
WOuld the IsNumeric function work like:

If IsNumeric(Request.Form("Quantity")) Then...

In this case, decimals are not allowed; the former solution seems to work.

Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top