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!

Form Validation

Status
Not open for further replies.

briggsc

Technical User
Jan 1, 2005
14
US
Hi and Thanks for your help!

I am working on this form. One of the text field I am using is for a Special Promotion Code. If the user enters the incorrect Promotion Code it should generate an error message. In the future this text field may have at least 10 valid promotion codes to this field. Currently I have only two valid promotion codes to the the text field. The code I created will only validate the first on (06teach)instead of both. Here's my code.


If Request.Form("code") <> "" Then
If not Trim(Request.Form("code")) = "06teach" Then
errs = addError("code", "(Not a Valid Special Promotion Code)")
ElseIf not Trim(Request.Form("code")) = "06med" Then
errs = addError("code", "(Not a Valid Special Promotion Code)")
End If
End If

Do you what I am missing?

Thanks Again for your help!
 
Coud just be me, but I don't see how any code can get through this If/ElseIf/End if statement.
Code:
If not Trim(Request.Form("code")) = "06teach" Then 
errs = addError("code", "(Not a Valid Special Promotion Code)")
06med is not = 06teach, so err = adderr.......
Code:
ElseIf not Trim(Request.Form("code")) = "06med" Then 
errs = addError("code", "(Not a Valid Special Promotion Code)")
and 06teach is not = 06med, so err = adderr.......
or no matter what, err = adderr........
Or have I missed something?
 
Thanks for responding! I must say I am fairly new to .asp.

Basicly what I want is.

If the the field is <>"" then

if the field = 06teach or 06med then

display error.


Does this sound all right?
 
One way:
If Request.Form("code") <> "" Then
If InStr(",06teach,06med,", "," & Trim(Request.Form("code")) & ",") = 0 Then
errs = addError("code", "(Not a Valid Special Promotion Code)")
End If
End If
Another way is to use the Select Case statement.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's okay I figured it out. I used a Select Case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top