I wanted to use the required option for the description field in my form, but it throws a validation error when it should not. For example, there are three levels - Software, Gold and Silver. Silver is the only level that does not display the description, but a validation error is still displayed even though the field is hidden.
I have added custom server side validation to run a couple of different checks in my form and they are working, so I figured I would try to do it for the description as well. When I add the following code to check if a description field is not empty, I get a validation error regardless if it has characters inputted or not. What am I missing?
<?php
if (($_POST['level'] == "Software" && empty($POST['description'])) || ($_POST['level'] == "Gold" && empty ($POST['description']))) {
$form->validation_errors['description'] = "Please enter up to a 650 character (including spaces) description of your company/organization";
return false;
}
?>
Also, is there a reason why the JS seems to not load on the Event Loop after Fail? The form initially loads several scripts, including one that populates price. However, when validation fails the scripts seem not to function any longer. I tried adding a JS Load on the Fail above the Event Loop but that isn't working either.
I have added custom server side validation to run a couple of different checks in my form and they are working, so I figured I would try to do it for the description as well. When I add the following code to check if a description field is not empty, I get a validation error regardless if it has characters inputted or not. What am I missing?
<?php
if (($_POST['level'] == "Software" && empty($POST['description'])) || ($_POST['level'] == "Gold" && empty ($POST['description']))) {
$form->validation_errors['description'] = "Please enter up to a 650 character (including spaces) description of your company/organization";
return false;
}
?>
Also, is there a reason why the JS seems to not load on the Event Loop after Fail? The form initially loads several scripts, including one that populates price. However, when validation fails the scripts seem not to function any longer. I tried adding a JS Load on the Fail above the Event Loop but that isn't working either.