I would like to put a default value in a single line text field (this field is required), but then produce an error message if the user leaves the default value unchanged when the form is submitted, so that the user must change the default value to something else.
Appnitro Software Forums » MachForm 2
Force user to change default value for single line text field
Started 6 months ago by williamansley | 3 posts |
-
Posted 6 months ago #
-
You need to customize "post-functions.php" file for this. for single line text, you can go to around line 198 ~ 200 and you will see these code :
if($validation_result !== true){ $error_elements[$element_id] = $validation_result; }then put these customization code bellow that line
if ($form_id ==24 && $element_id == 1) { if ($element_data == 'test') { $error_elements[$element_id] = "You need to fill the field"; } }That would do it.
In there I assume your form id is 24 and the field id is 1, with default value "test". You need to change those values with yours.MachForm Support
Posted 6 months ago # -
Thank you. This worked very well for me.
Posted 6 months ago #
Reply
You must log in to post.
