Sign in to follow this  
edd1986

[web] A problem with ASP validation

Recommended Posts

edd1986    168
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
BeanDog    1065
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this