Web Development with jQuery®

(Elliott) #1

Filtering a Selection (^) ❘ 37
id='contactFirstName'
name='contactFirstName'
size='25'
maxlength='50'
required='required' />





id='contactLastName'
name='contactLastName'
size='25'
maxlength='50'
required='required' />


id='contactNewsletter'
name='contactNewsletter'
value='1' />



id='contactNewsletterFormSubmit'
name='contactNewsletterFormSubmit'
value='Go' />




The preceding markup contains a simple newsletter sign-up form. It is combined with the following
CSS, Example 2-2.css:
body {
font: 16px Helvetica, Arial, sans-serif;
}
form#contactNewsletterForm {
margin: 10px;
padding: 10px;
border: 1px solid black;
background: yellow;
}
form#contactNewsletterForm div {
padding: 5px;
}
The following JavaScript, Example 2-2.js, is used to validate that required input has been provided
in the text input fi elds, and it disables the submit button upon pressing it, which prevents the user
from pressing the submit button multiple times in the event that the action of submitting the form
takes longer than desired.
[http://www.it-ebooks.info](http://www.it-ebooks.info)
Free download pdf