# [web] A problem with ASP validation

This topic is 4595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi. i'm trying to validate the details a user enters into a form, before i add the details into a database. I am getting really stuck with server side validation. what i basically want to do is:
if data has been entered
if data field is invalid - error msg
(repeated for all my fields)
else add data into table


I realise i need a nested if statement for this but i can't seem to get it right. A sample of my code is below. any help would be greatly appreciated
If id <> "" Then
If cid = "" Then Response.Write "Error"
If title = "" Then Response.Write "Error"
If genre = "" Then Response.Write "Error"
If dir = "" Then Response.Write "Error"
If star = "" Then Response.Write "Error"
If cost = "" Then Response.Write "Error"
If rel = "" Then Response.Write "Error"

Else
(Add data to database)
End With
End If


Thanks

##### Share on other sites
How about something like this?

Bool Okay = trueIf id <> "" Then Okay = falseIf cid = "" Then Okay = falseIf title = "" Then Okay = falseIf genre = "" Then Okay = falseIf dir = "" Then Okay = falseIf star = "" Then Okay = falseIf cost = "" Then Okay = falseIf rel = "" Then Okay = falseIf Okay then(Add data to database)elseResponse.Write "BAD, BAD MONKEY"End If

~BenDilts( void );

##### Share on other sites
That is an excellent idea. thank you very much :)

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×