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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Silly Newbie Question - Form Validation

Status
Not open for further replies.
May 13, 2008
24
US
Hello all,

I need to provide form validation checks for an updateable application website that I am constructing. I know how to check for length and in string values, but for some reason I cannot recall how to check for integers.

For example, I need to run a validation on a zip code field just to check in there are 5 digits. Also, I am going to check for SSN numbers, but I am going to segment the field into three fields (3 int, 2 int, 4 int) and then concatenate them through code. I need to check if there are the correct amount of digits in each field.

Also, just to be snazzy, I would like to prohibit the user from entering letters in these fields, but that is not as important.

I know there is probably a tutorial out there that addresses this, but I have not been able to find it. I have found simple validation tutorials, but none that address the integer question.

I appreciate any help in advance. Thank you so much! Even if someone could point me in the right direction of a helpful website or tutorial, I would be very grateful.

Thanks!!!

-JP
 
You could use a regular expression for both of these scenarios.

really basic patterns

Code:
Option Explicit

Dim regEx : Set regEx = New RegExp
regEx.Pattern = "^\d{5}$"

WScript.Echo CStr(regEx.Test(12445))
WScript.Echo CStr(regEx.Test("12345"))
WScript.Echo CStr(regEx.Test("1234"))
WScript.Echo CStr(regEx.Test("123456"))

WScript.Echo String(50, "=")
regEx.Pattern = "^\d{3}-\d{2}-\d{4}$" 'simple SSN pattern

WScript.Echo CStr(regEx.Test("123-45-6789"))
WScript.Echo CStr(regEx.Test("123-AB-6789"))



--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
You may use the IsNumeric and Len functions.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top