1 Replies - 2830 Views - Last Post: 11 July 2012 - 04:21 AM Rate Topic: -----

#1 julzxvi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-May 11

Error Trapping for Empty Form

Posted 10 July 2012 - 11:11 AM

Please help me with my error trapping... If textboxes were empty it should display, Fill up necessary fields but I have my condition and everything and its just blank! We were asked to use IsEmpty() function. I need modification with my conditional statement. We use ASP classic not .net. THANKS!


<!DOCTYPE html>

<html>
<head>
    <title>Page Title</title>
</head>

<body>
    <center><h1>Membership Form</h1></center>
<form method="post" action="index.asp">
    <label>LastName: </label> <input type="text" name="txtln">
    <label>FirstName:  </label> <input type="text" name="txtfn">
    <label>M.I.:  </label> <input type="text" name="txtmi"> <br>
    <label>Address:  </label> <input type="text" name="txtadd"> <br>
    <label>Username: </label> <input type="text" name="txtuser"> <br>
    <label>Password: </label> <input type="password" name="txtpw"> <br>
    <label>Confirm Password: </label> <input type="password" name="txtpw2"><br>
    
    <input type="submit" value="SUBMIT" name="btnsubmit"><input type="reset" value="RESET">
    
    </form>
<%

Dim lname, fname, middle, address, user, password
lname=trim(Request.Form("txtln"))
fname=trim(Request.Form("txtfn"))
middle=trim(Request.Form("txtmi"))
address=trim(Request.Form("txtadd"))
user=trim(Request.Form("txtuser"))
password=trim(Request.Form("txtpw"))
password2=trim(Request.Form("txtpw2"))
If (IsEmpty("lname") OR IsEmpty("fname") OR IsEmpty("middle") OR IsEmpty("address") OR IsEmpty("user") OR IsEmpty("password") OR IsEmpty("password2")) then
response.write("Please fill up the necessary fields!")
Else
response.write("Name: " &fname&" " &middle&" "&lname& "<br> Address:"&" "&address &"<br>Username: "&user&"<br>Password: "&password & "<br>Confirm Password: "&password2) 
End If
%>


</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: Error Trapping for Empty Form

#2 zeeshanef  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 71
  • Joined: 14-April 12

Re: Error Trapping for Empty Form

Posted 11 July 2012 - 04:21 AM

I don't think you should write variables name in double quotation, in if statement.

If (IsEmpty("lname") OR IsEmpty("fname") OR IsEmpty("middle") OR IsEmpty("address") OR IsEmpty("user") OR IsEmpty("password") OR IsEmpty("password2"))


you will never receive this message:
response.write("Please fill up the necessary fields!")

because all IsEmpty functions have string values in "double quotation" but not variables name.

This post has been edited by zeeshanef: 11 July 2012 - 04:25 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1