Is it possible to add validation for a dropdown element, such that the default choice (eg, --select ...--) is NOT valid, but any other choice is valid? I want to force the user to make a selection.
Appnitro Software Forums » MachForm 2
Input Validation
Started 6 months ago by christopherbrooks | 5 posts |
-
Posted 6 months ago #
-
This possible with small customization, edit your "includes/post-functions.php" file and go to around line 661 ~ 663 for these code :
if($validation_result !== true){ $error_elements[$element_data] = $validation_result; }then put these code bellow those line
$query = "select <code>option</code> from <code>ap_element_options</code> where form_id='$form_id' and option_id = '$element_data' and element_id = '$element_id' "; $result = do_query($query); $row = do_fetch_result($result); if ($row['option'] == "--select ...--") { $error_elements[$element_data] = "You need to select another options"; }make sure the option text is same with the one on your drop down (case sensitive)
PS : change
andin those code with backticksMachForm Support
Posted 6 months ago # -
Thank you for the suggestion. Can you clarify, I do not understand what you mean by:
change and in those code with backticksPosted 6 months ago # -
With some adjustment I am able to correctly test whether the drop down selection was the default (--Please select-- ) or something else. If default, you get an error when trying to continue, and if not, no error. However, the error is showing up on the last field of the form, not the field with the drop down default. So some further adjustment is apparently needed to get the error message to position on the correct field.
Posted 6 months ago # -
Got it! needed to use $error_elements[$element_id] rather than $error_elements[$element_data]
Posted 6 months ago #
Reply
You must log in to post.
