Mar 28th, 2012, 8:32 AM
(This post was last modified: Mar 28th, 2012, 8:44 AM by michatmaster7.)
So, I am just getting around to implementing this (after the client complained yesterday that the validation wasn't in place). Oops.
Here is the validation script I am trying to implement:
Here are the code snippets from the form:
and:
When I select the checkboxes, but do not enter a number in the text field, I get the appropriate error (from the validation script). However, when I DO NOT select the checkboxes, I get the same error (from the validation script).
I will again remove the validation script until I can get this to work properly.... Any help would be appreciated. Perhaps it's my own fault in coding?
Brandon
Disregard my last reply, I updated the code as below and all works without any hitches. Thank you again Ben for all your hard work on this!
Because I had given a "value" to the checkbox upon being selected, it affects the validation script syntax.
Thanks again!
Here is the validation script I am trying to implement:
PHP Code:
$rules[] = "if:good_sam_member!=,required,good_sam_number,Please enter your Good Sam MEMBERSHIP NUMBER.";
$rules[] = "if:escapees_member!=,required,escapees_number,Please enter your Escapees MEMBERSHIP NUMBER.";
Here are the code snippets from the form:
Code:
...
<input name="good_sam_member" type="checkbox" value="yes" <?php if (@$fields["good_sam_member"] == "yes") echo "checked"; ?> />
...
<input name="good_sam_number" size="36" type="text" value="<?=htmlspecialchars(@$fields["good_sam_number"])?>" />
...
and:
Code:
...
<input name="escapees_member" type="checkbox" value="yes" <?php if (@$fields["escapees_member"] == "yes") echo "checked"; ?> />
...
<input name="escapees_number" size="36" type="text" value="<?=htmlspecialchars(@$fields["escapees_number"])?>" />
...
When I select the checkboxes, but do not enter a number in the text field, I get the appropriate error (from the validation script). However, when I DO NOT select the checkboxes, I get the same error (from the validation script).
I will again remove the validation script until I can get this to work properly.... Any help would be appreciated. Perhaps it's my own fault in coding?
Brandon
Disregard my last reply, I updated the code as below and all works without any hitches. Thank you again Ben for all your hard work on this!
PHP Code:
$rules[] = "if:good_sam_member=yes,required,good_sam_number,Please enter your Good Sam MEMBERSHIP NUMBER.";
$rules[] = "if:good_sam_number!=,required,good_sam_member,Please check the box for Good Sam DISCOUNT.";
$rules[] = "if:escapees_member=yes,required,escapees_number,Please enter your Escapees MEMBERSHIP NUMBER.";
$rules[] = "if:escapees_number!=,required,escapees_member,Please check the box for Escapees DISCOUNT.";
Code:
...
<input name="good_sam_member" type="checkbox" value="yes" <?php if (@$fields["good_sam_member"] == "yes") echo "checked"; ?> />
...
<input name="good_sam_number" size="36" type="text" value="<?=htmlspecialchars(@$fields["good_sam_number"])?>" />
...
Code:
...
<input name="escapees_member" type="checkbox" value="yes" <?php if (@$fields["escapees_member"] == "yes") echo "checked"; ?> />
...
<input name="escapees_number" size="36" type="text" value="<?=htmlspecialchars(@$fields["escapees_number"])?>" />
...
Because I had given a "value" to the checkbox upon being selected, it affects the validation script syntax.
Thanks again!