Code to make this work:
JavaScript
You will notice a minimal amount of JavaScript. You only have to add a tag for including the script as well as initializing the validator.
It does not auto intialize in case you didn't want automatically check as people left the form, only as they click the submit button. This is
always a possibility with Validator.
<!-- in head tag -->
<script type="text/javascript" src="Validator.js"></script>
<!-- body tag onload call -->
<body onload="initializeValidator()">
HTML
you define your validation properties by adding the appropriate attributes and their values if they are required. This is a simple
process. There is "no" limit to the number of properties you can add to your form fields, other than the max number of validation tools provided
by the Validator library. It is best to avoid adding the same validation check twice to the same field, as the results are indeterminate.
<form action="" method="" accept-charset="utf-8">
<h2>Validation Test:
</h2>
<p>This test shows the form within a series of label, and div elements.
</p>
<div><label for="firstName">first name: (with pop-up)
</label>
<input id="firstName" name="MyFirstName" required="required" popup="popup" /></div>
<input id="test2" name="lastName" required="required" /></div>
<div><label for="longstuff">keep from too long:
</label>
<textarea id="longstuff" name="notToLongStuff" maxlen="95" maxwords="3">hi!
</textarea></div>
<input id="maxNum" name="MaxValue" maxval="35" /></div>
<input id="email" name="email" email="email" /></div>
<input id="phone" name="phone" usphone="usphone" /></div>
<input id="price" name="price" uscurrency="true" /></div>
<input type="submit" value="Continue" />
</form>
CSS
.errMsg {
background-color: #fcc;
font-weight: bold;
color: #900;
margin: 2px;
padding: 6px;
border: #900 2px solid;
}
.requiredText {
color: #d00;
font-style: italic;
}
label {
float: left;
width: 155px;
text-align: right;
}
form div {
clear: both;
}