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

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

XHTML Form Text Field Validation and Formatting with JavaScript

Listing 21.1 is an example of a traditional XHTML 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 XHTML Document Using a Standard XHTML Form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>
<form name="MyForm">
<table>
<tr><td>First name:</td>
    <td>&nbsp</td>
    <td><input type="text" name="FirstName" size="20" value="" /></td></tr>
<tr><td>Last name:</td>
    <td>&nbsp</td>
    <td><input type="text" name="LastName"  size="20" 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 />
<em>Jim O'Donnell, <a href="mailto:jim@odonnell.org">jim@odonnell.org</a></em>
</body>
</html>
					

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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