Welcome Guest, Not a member yet? Register   Sign In
Validation - optional fields + callbacks + other rules
#3

[eluser]coolfactor[/eluser]
The fix is simply to remove the check for a callback function. Here's the same code as above, but with the callback removed:

Code:
// Is the field required?  If not, if the field is blank  we'll move on to the next test
if ( ! in_array('required', $ex, TRUE))
{
    if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
    {
        continue;
    }
}

Callbacks are then treated the same as other functions. If the field is optional, they are only called if the field exists in $_POST and has a non-empty value.


Messages In This Thread
Validation - optional fields + callbacks + other rules - by El Forum - 10-03-2007, 04:45 PM
Validation - optional fields + callbacks + other rules - by El Forum - 10-05-2007, 05:42 AM
Validation - optional fields + callbacks + other rules - by El Forum - 10-05-2007, 08:53 AM
Validation - optional fields + callbacks + other rules - by El Forum - 10-16-2007, 06:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB