I am trying to figure out which Validation scheme takes precedent: ValidateRegularExpression or ValidateAsNot Empty. See the following example:
Code: Select all
$registration->AddInput(array(
"TYPE"=>"text",
"NAME"=>"unitaddress1",
"ID"=>"unitaddress1",
"TABINDEX"=>13,
"SIZE"=>40,
"MAXLENGTH"=>100,
"ValidateOnlyOnServerSide"=>1,
"ValidateRegularExpression"=>"^[0-9A-Za-z ''-]+$",
"ValidateRegularExpressionErrorMessage"=>"Please enter a valid street address.",
"ValidateAsNotEmpty"=>1,
"ValidateAsNotEmptyErrorMessage"=>"Please enter your street address.",
"LABEL"=>$registrationfields['unitaddress1']
));
$registration->AddInput(array(
"TYPE"=>"text",
"NAME"=>"unitaddress2",
"ID"=>"unitaddress2",
"SIZE"=>40,
"TABINDEX"=>14,
"MAXLENGTH"=>100,
"ValidateOnlyOnServerSide"=>1,
"ValidateRegularExpression"=>"^[0-9A-Za-z ''-]+$",
"ValidateRegularExpressionErrorMessage"=>"Please enter a valid street address.",
"LABEL"=>$registrationfields['unitaddress2']
));
As you can see, my form contains two address lines. The first line must have something in it
AND it must contain valid characters ("^[0-9A-Za-z ''-]+$"). The second line is not a required field, but if there is any data in it it must also contain valid characters. It appears however that since an empty field doesn't match the regex, it doesn't validate. As a workaround, I've changed the second field to use the following Regex:
This does the trick for now, but I would like to know what the precedence various validation schemes have over one another. I suppose I could look through the code (already have added some cool new features to the form class, such as adding field specific validation error messages that appear with each field all at once), but if anyone knows the quick answer, that would be great. Thanks all!
Tripps