I'm trying to figure out the best way to validate this form. This is a simple email sending script in PHP. Please don't suggest a canned script or something. I have to write this from scratch.
I read contact information from a database which I display out to the browser. Some of the info is changable and some is not. I will have numerous rows and 4 columns in the table part. The first field in each row is a checkbox and the user needs to be able to click check all or clear all button to check or clear this check box. Here is the column info:
checkbox
company (static)
name (changeable)
email address (changable)
For each row, if the checkbox is selected, then the name and email fields cannot be empty.
Then, I have these text fields:
from name
from email
cc name
cc email
subject
message (textarea)
All of these text fields are required.
Would it be better to give each column field a different name, like:
<input type="checkbox" name="cb_1" value="1" id="cb_1" />
<input type="hidden" id="Company_1" name="Company_1" value="company1" />
<input type="text" class="textBox" id="Name_1" name="Name_1" value="Jon Smith" size="35" />
<input type="text" class="textBox" id="Email_1" name="Email_1" value="john@anywhere.com" size="50" />
or would this be better?
<input type="checkbox" name="cb" value="1" id="cb" />
<input type="hidden" id="CompanyName" name="CompanyName" value="company1" />
<input type="text" class="textBox" id="Name" name="Name" value="Jon Smith" size="35" />
<input type="text" class="textBox" id="Email" name="Email" value="john@anywhere.com" size="50" maxlength="255" />
My problem is that I'm having trouble getting the checkbox working along with the other validations. I'm a great PHP programmer, but terrible at JavaScript. Any help would be greatly appreciated.
I read contact information from a database which I display out to the browser. Some of the info is changable and some is not. I will have numerous rows and 4 columns in the table part. The first field in each row is a checkbox and the user needs to be able to click check all or clear all button to check or clear this check box. Here is the column info:
checkbox
company (static)
name (changeable)
email address (changable)
For each row, if the checkbox is selected, then the name and email fields cannot be empty.
Then, I have these text fields:
from name
from email
cc name
cc email
subject
message (textarea)
All of these text fields are required.
Would it be better to give each column field a different name, like:
<input type="checkbox" name="cb_1" value="1" id="cb_1" />
<input type="hidden" id="Company_1" name="Company_1" value="company1" />
<input type="text" class="textBox" id="Name_1" name="Name_1" value="Jon Smith" size="35" />
<input type="text" class="textBox" id="Email_1" name="Email_1" value="john@anywhere.com" size="50" />
or would this be better?
<input type="checkbox" name="cb" value="1" id="cb" />
<input type="hidden" id="CompanyName" name="CompanyName" value="company1" />
<input type="text" class="textBox" id="Name" name="Name" value="Jon Smith" size="35" />
<input type="text" class="textBox" id="Email" name="Email" value="john@anywhere.com" size="50" maxlength="255" />
My problem is that I'm having trouble getting the checkbox working along with the other validations. I'm a great PHP programmer, but terrible at JavaScript. Any help would be greatly appreciated.