Welcome Guest, Not a member yet? Register   Sign In
Form Validation validating blank values with min_length and valid_email rules
#13

If a field is required, then you have to fill it in. If it is not, you do not have to.

If you have an email field, that is not required, and the user does not fill it in, then it should not fail the validation, even if the validation says min_length 50, valid email, or whatever. It is not required, so no input is a pass.

With your city field example above, if I had a user presented with 12 possible fields that could be updated, you would prefill this with the existing data, and if he saved the form, all the possible fields that could have been updated, are updated. You might test to see if the field had changed but why bother, just update all 12.

Suppose a user had an email, but now blanked it out, if you do not update blank fields, how do you know the user wanted to remove his email address?

I would normally do this by the user selecting exactly what field he wanted to update. Say he chose his email address, then only the email address input is displayed, prefilled, for him to update. If he emptied it and pressed save, the field (assuming it is not required) would be updated to blank or null.

But, if the form validation does not work the way you want it to, you customise it to suit (which might be ill advised) or just do your own validation with a regex and some issets and whatever else you wanted.

Paul.
Reply


Messages In This Thread
RE: Form Validation validating blank values with min_length and valid_email rules - by PaulD - 10-17-2017, 01:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB