homework, javascript, form validation
<p>I need to do a javascript form validation.
I would like to validate each field as the user clicks or tabs to the next field. 
(onBlur ?)
I have to validate the email for the correct form. As with Address and Phone.
I'm not sure where to put the validation code in the HTML form.
Validation needs to be done on the browser before sending to the server.
I would appreciate any advice or tutorials. </p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;

&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

&lt;title&gt;Request Form&lt;/title&gt;


   &lt;meta name="Description" content="This webpage is for Customer Demographics" /&gt;
   &lt;meta name="Keywords" content="Rhonda , email, " /&gt;
   &lt;meta name="author" content="Rhonda " /&gt;
   &lt;meta name="copyright" content="Copyright 2010 Rhonda , All Rights 

Reserved" /&gt;
   &lt;meta name="robots" content="all" /&gt;
   &lt;meta name="revisit-after" content="15 days" /&gt;
   &lt;meta name="rating" content="safe for kids" /&gt;

&lt;script type="text/javascript" &gt;

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;body style="background-color:lightsteelblue"&gt;


&lt;h1&gt;
        Welcome Kudler Fine Foods customer.
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt; 
    Please enter the following details in order
    to be added to our preferred customer mailing list:
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
&lt;/h1&gt;       

    &lt;form action=""&gt;
    &lt;fieldset&gt;
    &lt;legend&gt;Personal information:&lt;/legend&gt;

&lt;p&gt;

        First Name:

        &lt;br /&gt;

        &lt;input type="text" name="txtFName" VALUE="" SIZE="30" MAXLENGTH="50"  /&gt;

&lt;/p&gt;

&lt;p&gt;

         Middle Initial:

         &lt;br /&gt;

         &lt;input type="text" name="txtMiddle" VALUE="" SIZE="5" MAXLENGTH="3" /&gt;

&lt;/p&gt;

&lt;p&gt;

    Last Name:

        &lt;br /&gt;

        &lt;input type="text" name="txtLName" VALUE="" SIZE="30" MAXLENGTH="50" /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;/fieldset&gt;
    &lt;/form&gt;

&lt;/p&gt;       

    &lt;form action=""&gt;
    &lt;fieldset&gt;
    &lt;legend&gt;Address:&lt;/legend&gt;


&lt;p&gt;
    Mailing Address: 
    &lt;br /&gt;
    &lt;br /&gt;
    Street &lt;INPUT TYPE="TEXT" NAME="Street" VALUE="" SIZE="25"  

MAXLENGTH="50" /&gt;
    &lt;br /&gt;
    City   &lt;INPUT TYPE="TEXT" NAME="City" VALUE="" SIZE="35" MAXLENGTH="50"     

/&gt;&lt;br /&gt;
    State  &lt;INPUT TYPE="TEXT" NAME="State" VALUE="" SIZE="2" MAXLENGTH="2"  

/&gt; &lt;br /&gt;
    Zip Code &lt;INPUT TYPE="TEXT" NAME="State" VALUE="" SIZE="5"      

MAXLENGTH="5" /&gt; &lt;br /&gt;
        &lt;br /&gt;
    &lt;br /&gt;

    &lt;/fieldset&gt;
    &lt;/form&gt;
&lt;/p&gt;


&lt;p&gt;
    Email Address:    
    &lt;br /&gt;

    &lt;INPUT TYPE="TEXT" NAME="Email" VALUE="" SIZE="25" MAXLENGTH="50" /&gt;
&lt;/p&gt;


&lt;p&gt; 
    Telephone Number:
    &lt;br /&gt;
    &lt;input type="TEXT" NAME="AreaCode" VALUE="" SIZE="3" MAXLENGTH="3"/&gt; 
    &lt;INPUT TYPE="TEXT" NAME="Telephone" VALUE="" SIZE="7" MAXLENGTH="7" /&gt; 
    &lt;br /&gt;
&lt;/p&gt;        


&lt;!--NOTES 
This part was not mandantory. I was just trying some of the extra ways of adding input that the book discussed--&gt;       

&lt;p&gt;     
    Gender:
    &lt;br /&gt;
    &lt;input type="radio" name="sex" value="male" /&gt; Male&lt;br /&gt;
        &lt;input type="radio" name="sex" value="female" /&gt; Female

&lt;/p&gt;

&lt;p&gt; 
    How did you hear about us?
    &lt;br /&gt;
    &lt;input type="checkbox" name="Friend" value="Friend" /&gt; From a friend
    &lt;br /&gt;
    &lt;input type="checkbox" name="Advertisement" value="Advertisement" /&gt;    

Store Advertisement
    &lt;br /&gt;
    &lt;input type="checkbox" name="Online" value="Online" /&gt; From Online
    &lt;br /&gt;
    &lt;input type="checkbox" name="Other" value="Other" /&gt; Other
    &lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;

    How do you wish to be contacted?
    &lt;br /&gt;
    &lt;form action=""&gt;
    &lt;select name="contact"&gt;
    &lt;option value="telephone"&gt;Telephone&lt;/option&gt;
    &lt;option value="E-mail"&gt;E-mail&lt;/option&gt;
    &lt;option value="Snail-mail"&gt;Snail-mail&lt;/option&gt;
    &lt;/select&gt;
    &lt;/form&gt;

&lt;/p&gt;

&lt;p&gt;

&lt;form&gt;  
    &lt;form name="input" 
    &lt;form action="acknowledgement.html"&gt;
    &lt;INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit and Verify"&gt; 
&lt;/form&gt;             
&lt;/p&gt;

&lt;form&gt;  

&lt;p&gt;

&lt;input type="reset" Name="resetbutton" Value="Reset Form Now"&gt;

&lt;/p&gt;


&lt;/form&gt;
&lt;p&gt;&lt;a href="#top"&gt;Back to Top&lt;/a&gt;&lt;/p&gt; 

&lt;/body&gt;

&lt;/html&gt;

Code for Acknowledgement Page:

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;

&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

&lt;title&gt;Acknowledgement Page&lt;/title&gt;


   &lt;meta name="Description" content="This webpage is for  Customer Demographics" /&gt;
   &lt;meta name="Keywords" content=" email, " /&gt;
   &lt;meta name="author" content="Rhonda " /&gt;
   &lt;meta name="copyright" content="Copyright 2010 Rhonda, All Rights Reserved" /&gt;
   &lt;meta name="robots" content="all" /&gt;
   &lt;meta name="revisit-after" content="15 days" /&gt;
   &lt;meta name="rating" content="safe for kids" /&gt;


&lt;/head&gt;

&lt;body&gt;

&lt;body style="background-color:lightsteelblue"&gt;

&lt;script type="text/javascript"&gt;&lt;/script&gt;

&lt;h1&gt;Request Confirmation&lt;/h1&gt;
&lt;p&gt;Your request has been received.&lt;/p&gt;
&lt;p&gt;Thank you. You will be added to our customer mailing list&lt;/p&gt;"
&lt;p&gt;Please use your browsers back button or, &lt;/p&gt;"




&lt;address&gt;

&lt;a href="index.htm"&gt;Click here&lt;/a&gt;

&lt;/address&gt;

&lt;/body&gt;

&lt;/html&gt;
</code></pre>
