How can I add a input field to a form that is validated but optional. I use Auto Server Side Validation for form validation and I want to have a text field that can only contain alphanumeric content. If I set the validation action to validate the input field as an alphanumeric content then it will not allow empty values. I don't quite understand what is the point of having a separate 'Not Empty' validation rule when all the validation rules require that the content is not empty.
I checked the code and found this regular expression
I would change the plus sign at the end of expression to ?, but that is just my opinion.
Got any ideas for a solution?
-Rennye
I checked the code and found this regular expression
function validate_alphanumeric($str, $form){
if(isset($form->data[$str])){
return preg_match('/^[a-z0-9 ._-]+$/i', $form->data[$str]);
}
}
I would change the plus sign at the end of expression to ?, but that is just my opinion.
Got any ideas for a solution?
-Rennye