• Advertisement
Sign in to follow this  

[web] A problem with ASP validation

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
How about something like this?


Bool Okay = true

If id <> "" Then Okay = false
If cid = "" Then Okay = false
If title = "" Then Okay = false
If genre = "" Then Okay = false
If dir = "" Then Okay = false
If star = "" Then Okay = false
If cost = "" Then Okay = false
If rel = "" Then Okay = false

If Okay then
(Add data to database)
else
Response.Write "BAD, BAD MONKEY"
End If




~BenDilts( void );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement