• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 21. Using JavaScript to Create S... > HTML Form Text Field Validation and ...

HTML Form Text Field Validation and Formatting with JavaScript

Listing 21.1 is an example of a traditional HTML page used to gather input from a user. Take a closer look at a few of the elements of this page.

Code Listing 21.1. Form.htm—An HTML Document Using a Standard HTML Form

<HTML>
<HEAD>
<TITLE>Forms Verification</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Credit Card Payment Information</H1>
<HR>
<B>All information must be entered before the form can be submitted...</B>
<HR>
<FORM NAME="MyForm">
<TABLE>
<TR><TD>First Name:</TD>
    <TD>&nbsp</TD>
    <TD><INPUT TYPE=TEXT NAME="FirstName" SIZE=21 VALUE=""></TD></TR>
<TR><TD>Last Name:</TD>
    <TD>&nbsp</TD>
    <TD><INPUT TYPE=TEXT NAME="LastName"  SIZE=21 VALUE=""></TD></TR>
<TR><TD COLSPAN=4><HR></TD></TR>
<TR><TD>Payment Date:</TD>
    <TD>&nbsp</TD>
    <TD><INPUT TYPE=TEXT NAME="PayDate"   SIZE=10 VALUE=""></TD>
    <TD>(enter as mm/dd/yy)</TD></TR>
<TR><TD>Payment Amount:</TD>
    <TD><B>$</B></TD>
    <TD><INPUT TYPE=TEXT NAME="Amount"    SIZE=10 VALUE=""></TD></TR>
<TR><TD>Credit Card Number:</TD>
    <TD>&nbsp</TD>
    <TD><INPUT TYPE=TEXT NAME="CCNumber"  SIZE=20 VALUE=""></TD>
    <TD>(must be 13 or 16 digits long)</TD></TR>
<TR><TD>Expiration Date:</TD>
    <TD>&nbsp</TD>
    <TD><INPUT TYPE=TEXT NAME="ExpDate"   SIZE=10 VALUE=""></TD>
    <TD>(enter as mm/dd/yy)</TD></TR>
</TABLE>
<HR>
<INPUT TYPE=SUBMIT NAME="MySubmit" SIZE=20 VALUE="SUBMIT INFORMATION">
</FORM>
<HR>
<ADDRESS>
Jim O'Donnell, <A HREF="mailto:odonnj@rpi.edu">odonnj@rpi.edu</A>
</ADDRESS>
</BODY>
</HTML>


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint