Hello all.
I am working with a form where there is a text field, two checkboxes, and another text field. Both text fields need to be required, and either of the check boxes have to be checked.
Below is an example of the form that I have created.
[code]
<form name=’merch_frm’ action=’merch.php’ method=’post’>
<input name=”txtOne” type=”text” id=”txtOne”>
<br/>
Check One:
<input name=”chkOne” type=”checkbox” id=”chkOne” value=”checkbox”>
<br/>
Check Two:
<input name=”chkTwo” type=”checkbox” id=”chkTwo” value=”checkbox”>
<br/>
Input:
<input name=”txtTwo” type=”text” id=”txtTwo”><br/>
<input type=”submit” name=”Submit” value=”Submit”>
<form>
I’ve seen several ways that forms get evaluated, and I would like my error message to list the errors according to what was incorrect, not one at a time. For example:
*error1 (if applicable)
*error3 (if applicable)
I have tried creating a for loop in PHP to do this, but it’s not doing what I want. Below is what I have:
[code]
<?php
for ($i=0; $i<=3; $i++) {
if ($txtOne==””) {
echo ‘wrong 1’;
}
else if ($chkOne==”” || $chkTwo==””) {
echo ‘wrong2’;
}
else if ($txtTwo==””) {
echo ‘wrong3’;
break;
}
}
Can anyone tell me what I’m doing wrong?
Thanks,
Brian