Page 1 of 1

Check if user has filled the required fields

Posted: Wed May 28, 2003 8:18 am
by vipul73
How do I check if the user has filled the required fields and if the email address of the user is valid or not.

The required fields here are:

Name
Address1
Interest
E-mail
Age Confirmation

Code: Select all

<form name="form1" method="post" action="mail.php">
  <p>Name* : 
    <input name="Name" type="text" id="Name">
  </p>
  <p>Address1*: 
    <input name="Address1" type="text" id="Address1">
  </p>
  <p>Address2: 
    <input name="Address2" type="text" id="Address2">
  </p>
  <p>City: 
    <input name="City" type="text" id="City">
  </p>
  <p>Interest*: 
    <select name="Interest">
      <option selected>----- Select -----</option>
      <option value="Dance">Dance</option>
      <option value="Singing">Singing</option>
      <option value="Drama">Drama</option>
    </select>
  </p>
  <p>E-mail*: 
    <input name="email" type="text" id="email">
  </p>
  <p> Age Confirmation*: 
    <input name="age" type="checkbox" id="age" value="yes">
    Yeah I am over 13</p>
  <p> 
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">
  </p>
</form>

Posted: Wed May 28, 2003 8:31 am
by twigletmac
When you process the form you check to see if fields (once trimmed) are empty or not and handle accordingly. To validate the e-mail address you would most likely use a regular expression which won't tell you whether the e-mail is real or not, just if it looks like an e-mail. There were some e-mail validation scripts posted on the forum not that long back that use regular expressions plus a bit more.

Mac

Posted: Thu Jun 12, 2003 2:58 pm
by vipul73
Thanks a lot twigletmac you have taken your valuable time to respond to my queries and being patient with me

I have been able to complete the website niftyonline.com upto my satisfaction. I know you would be able to suggest a lot of better things after visiting the site and am ready for the brickbats.

Thanx once again.