Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: validation help needed please!!!


Message #1 by "patrick leslie" <ales260@a...> on Tue, 23 Apr 2002 16:40:31
hi all,
     i'm  new  to asp. i am trying to validate some fields  in my access 
asp.  i do i do that. i have written some code but each time i run it 
nothing happen. can someone please have a look at my code and tell me what 
i am doing wrong

here is my code
thank all 
leslie

'check for required fields
<%
if objconn = server.CreateObject("ADODB.Connection")
objConn. open "DSN="padda"
if objconn.Errors.count > 0 Then
set objError = server.CreateObject("ADODB.Error")
Dim blnCriticalError
newusername = TRIM( Request( "newusername" ) )
newpassword = TRIM( Request( "newpassword" ) )
email = TRIM( Request( "email" ) )
street = TRIM( Request( "street" ) ) 
city = TRIM( Request( "city" ) )
county = TRIM( Request( "county" ) )
postcode = TRIM( Request( "postcode" ) )
IF newUser <> " " THEN
IF newusername =  " " THEN
  Response.Write " you did not enter your name!"
  END IF
IF newpassword =  " " THEN
  Response.Write " you did not enter your password!"
  END IF
IF email =  " " THEN
  Response.write " you did not enter your email!"
  END IF
IF street =  " " THEN
  Response.Write " you did not enter your street!"
  END IF
IF city =  " " THEN
  Response.Write " you did not enter your city!"
  END IF
IF postcode =  " " THEN
  Response.Write " you did not enter your postcode!"
  END IF
  IF usernameTaken( newUsername ) THEN
    Response.Write " The username you entered has already " &_
"been chosen by a previous user. Please select " &_
"a new username"
END IF
%> 
Message #2 by "Charles Mabbott" <aa8vs@m...> on Tue, 23 Apr 2002 12:34:47 -0400
Without some testing myself, this may not be correct but;

Is the field truly empty or does it have a single blank?

Is the field is empty and you are checking for a blank
condition it will not work.

Have you considered length(newuser) > 1 as non-blank
I suspect it may not actually be blank.

Another thing to consider is ""  rather than " " but I
did not care for this myself and went with previous one
using length for intial test.

Regards,
Chuck

>From: "patrick leslie" <ales260@a...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] validation help needed please!!!
>Date: Tue, 23 Apr 2002 16:40:31
>
>hi all,
>      i'm  new  to asp. i am trying to validate some fields  in my access
>asp.  i do i do that. i have written some code but each time i run it
>nothing happen. can someone please have a look at my code and tell me what
>i am doing wrong
>
>here is my code
>thank all
>leslie
>
>'check for required fields
><%
>if objconn = server.CreateObject("ADODB.Connection")
>objConn. open "DSN="padda"
>if objconn.Errors.count > 0 Then
>set objError = server.CreateObject("ADODB.Error")
>Dim blnCriticalError
>newusername = TRIM( Request( "newusername" ) )
>newpassword = TRIM( Request( "newpassword" ) )
>email = TRIM( Request( "email" ) )
>street = TRIM( Request( "street" ) )
>city = TRIM( Request( "city" ) )
>county = TRIM( Request( "county" ) )
>postcode = TRIM( Request( "postcode" ) )
>IF newUser <> " " THEN
>IF newusername =  " " THEN
>   Response.Write " you did not enter your name!"
>   END IF
>IF newpassword =  " " THEN
>   Response.Write " you did not enter your password!"
>   END IF
>IF email =  " " THEN
>   Response.write " you did not enter your email!"
>   END IF
>IF street =  " " THEN
>   Response.Write " you did not enter your street!"
>   END IF
>IF city =  " " THEN
>   Response.Write " you did not enter your city!"
>   END IF
>IF postcode =  " " THEN
>   Response.Write " you did not enter your postcode!"
>   END IF
>   IF usernameTaken( newUsername ) THEN
>     Response.Write " The username you entered has already " &_
>"been chosen by a previous user. Please select " &_
>"a new username"
>END IF
>%>


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


  Return to Index