Welcome Guest, Not a member yet? Register   Sign In
How do I validate non-required fields?
#10

[eluser]Skyscraper[/eluser]
Okay, I've figured out where the bug lies. In system/libraries/Form_validation.php line 335 you can see:
Code:
if (isset($_POST[$field]) AND $_POST[$field] != "")
This considers "not set" and "set but empty string" to be the same thing, so when _execute line 488 occurs, it sees you don't have "required" as a validation rule and does not apply your "min_length" rule because it thinks the value is "not set" (null) even though it's "set but empty string".

To fix this, simply comment out the second half of the conditional:
Code:
if (isset($_POST[$field])/* AND $_POST[$field] != ""*/)
(Or extend the Form_validation.php class)


Messages In This Thread
How do I validate non-required fields? - by El Forum - 08-04-2013, 10:32 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 01:56 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 05:01 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 05:59 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 06:41 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 07:13 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 07:29 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 08:12 AM
How do I validate non-required fields? - by El Forum - 08-05-2013, 10:38 AM
How do I validate non-required fields? - by El Forum - 08-10-2013, 07:19 PM
How do I validate non-required fields? - by El Forum - 08-11-2013, 02:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB