Validating data ... read on...

Results 1 to 2 of 2

Thread: Validating data ... read on...

  1. #1
    Join Date
    Dec 1969

    Default Validating data ... read on...

    I know I posted this in ASP Q & A but I really didnt get an answer I could use I hope someone can help<BR>----------------------------------------<BR>Ok well I have a registration page that gets info from the user, that page passes the info to a processing page which checks all the fields and then if something is wrong it re-displays the form along with where the error is. For example say I entered the username incorrect (eg with a space) I want the processing page to re-show the form page except I want to make a message saying "The username you entered is incorrect" and I want the tile where it would say: <BR>______________________ <BR>username:&#124____________&#124 (this is an input field) <BR><BR>I want the username to have a different color, say red so people know (along with the message) where they screwed up. <BR><BR>This is how I have my process page so far. It assigns the data to variables then does a check on each variable using regular expressions (passes the variable and the regexp to a function) where it Tests it if it is ok then goes to the next if statement which is the same as the first, etc until all variables are checked. Here is a sniplet of the code (dont blame me if its messy its just the way it looks here): <BR><BR>if checkstring (username, "^[a-zA-Z0-9]w{2,17}$") Then <BR>if (password = password2) Then <BR>if checkstring (password, "^[a-zA-Z0-9]w{2,17}$") Then <BR>if checkstring (email, ^w+[w-.]*@w+((-w+)&#124(w*)).[a-z]{2,3}$) <BR>if (len(fname) &#062; 0) AND (len(lname) &#062; 0) <BR>If (CountryID = 1 AND len(potal) = 5) OR (CountryID = 2 AND len(potal) &#062; ) Then <BR>&#039;add to database <BR>Else If (CountryID &#060;&#062; 1 OR CountryID &#060;&#062; 2) <BR>&#039;add to database <BR>Else <BR>&#039;error <BR>End if <BR><BR>Else <BR><BR>End if <BR>Else <BR><BR>End if <BR>Else <BR><BR>End if <BR>Else <BR><BR>End if <BR><BR>Else <BR><BR>End if <BR><BR>the function and the regexp are fine. Now say that one of the variables prooves false in the regexp I want to display the whole original form with the main error message along with a highlighted title of where the error occured. I was thinking of passing it everytime to a function but then that didn&#039;t make sense as I was coding it. I am stumped. It seems like something really simple and I see it everywhere they have registrations, but for some reason I cant get it. ARGHHHH <BR><BR>lol <BR>please help <BR><BR>Thanks <BR>Mike M <BR>

  2. #2
    Join Date
    Dec 1969

    Default First Off you are missing

    some THEN s at the end of you if statements.<BR><BR>I would change the format to of the if&#039;s also to something like this<BR><BR>If something then<BR><BR>End If<BR><BR><BR>If somethingelse then<BR><BR>End If<BR><BR><BR>If it fails a test say the first have a string error variable that you concentanate errnumbers on to eg<BR><BR>myErr = myErr & ",1"<BR><BR>myErr = myErr & ",2" for the second error etc<BR><BR>Then pass this var to the form page. in your form page then check this var to see if need a mesage or highlight eg<BR><BR>&#060;%<BR>if instr(errstr,"1")&#060;&#062;0 Then <BR> Response.Write "&#060;b&#062;Input UserName&#060;/b&#062;"<BR>Else<BR> Response.Write "Input UserName"<BR>End if<BR><BR>etc<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts