design92
Junior Member
Hi every1,
First of all, I have no idea how to create javascript.
I have to create contact form (I have already built it, please find attachement) validated by JavaScript following client requirments as shown below:
I know it could be validated by PHP much more simple, but JavaScript is necessary.
Please find attached files - .html file and .css.
All the best,
Design92
First of all, I have no idea how to create javascript.
I have to create contact form (I have already built it, please find attachement) validated by JavaScript following client requirments as shown below:
Code:
First Name-
Mandatory – make sure that an entry has been made in this field.
Second Name –
Mandatory - – make sure that an entry has been made in this
field.
House number or name – Mandatory –
make sure that an entry has been made in this field.
Street name – Mandatory
- – make sure that an entry has
been made in this field.
Town – Mandatory - –
make sure that an entry has been made in this field.
Post Code – Mandatory - –
make sure that an entry has been made in this field.
Mobile – Must have an entry if Home is blank, if an entry has
been made strip out all non-numeric characters.
Home – Must have an entry if Mobile is blank, if an entry has
been made strip out all non-numeric characters.
Email –
Mandatory, plus check the
format of the email address entered – it must contain an @ symbol at some point
after the first character followed by a dot at some point after the third
character – the dot cannot be the last character.
Newspapers Read – if one of the choices is ‘Other’
then the ‘State one other Newspaper you read’ field becomes
mandatory.
State one other Newspaper you read –Mandatory if the ‘Other’
option is chosen in the Newspapers Read field.
Comments – Mandatory and must contain at least 15
characters.
When the Submit button is clicked the JavaScript will call a function which will
validate the entries made on the form.
A validation with errors will issue an appropriate JavaScript alert message to
indicate fields in error. The cursor will also be focussed on the first field in
error.
A validation with no errors will issue a JavaScript alert message to read ‘Thank
you for your enquiry’.
When the Reset button is clicked all fields in the Form will be cleared of entries
and the cursor will be focussed back to the first field at the top of the form
I know it could be validated by PHP much more simple, but JavaScript is necessary.
Please find attached files - .html file and .css.
All the best,
Design92