This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Select field Required
Started 16 years ago by MikeBWD | 5 posts |
-
Hi All
By default you get (without setting default)
'<option value="" selected="selected"></option>'
and have an empty field just
change to:
'<option value="1" selected="selected">Please select</option>'
(by setting default) and client can submit the form with "Please select" selectedis there a work around for this?
thanks MikePosted 16 years ago # -
Let me clarify this.
So you would like to have a select/drop down field, set as required and the default value is "Please select", but client shouldn't be able to submit "Please select".
Am I correct?
MachForm Founder
Posted 16 years ago # -
Hi Yuniar, I'll finish this post...
I'm in the same predicament. As you described, I have a drop down field which is populated with email addresses and is required. For my default I have "Please select". If I submit the form with "Please select" in the field there are no indications that this field needs attention. It would be ideal if the form sees that this default text is not an email address and thus error.Thanks!
Posted 16 years ago # -
Hi,
You can modifiy "includes/common-validator.php" file to add some validation. I assume your "please select" text located on first value of "Drop down element", so it will have value = "1".
Now search around line 30 ~ 39 on "includes/common-validator.php" file, you'll find these code :
function validate_required($value){ $value = $value[0]; if(empty($value) && (($value != 0) || ($value != '0'))) ){ //0 and '0' should not considered as empty return VAL_REQUIRED; }else{ return true; } }
replace with this one
function validate_required($value){ $value = $value[0]; if((empty($value) && (($value != 0) || ($value != '0'))) || ($value == '1') ){ //0 and '0' should not considered as empty return VAL_REQUIRED; }else{ return true; } }
MachForm Support
Posted 16 years ago # -
That did it, thanks!
Posted 16 years ago #
Reply
You must log in to post.