forms class feature: OR field validation
Posted: Tue Jul 27, 2004 12:24 pm
I'm trying to develop a ServerValidationFunction (unless one is already present or there's a workaround) which basically does an OR validation on two fields. For example, I've got two fields: business phone or evening phone.
As you can see, I've got a number of lines commented out as I've tried to find something that works. What I would like to have happen is for at least one of the fields has a valid number. It can be either, or both, but at least one must contain a number. Take a look at my post on regex vs. empty fields here as well for a related topic. Anyone have any suggestions as to how to begin? TIA!
Code: Select all
$registration->AddInput(array(
"TYPE"=>"text",
"NAME"=>"businessphone",
"ID"=>"businessphone",
"TABINDEX"=>18,
"SIZE"=>30,
"MAXLENGTH"=>30,
"ValidateOnlyOnServerSide"=>1,
"ValidateRegularExpression"=>"^[0-9]{3}([- \.])?[0-9]{3}([- \.])?[0-9]{4}$",
"ValidateRegularExpressionErrorMessage"=>"Please enter a valid 10 digit phone number.",
//"ValidateAsNotEmpty"=>1,
//"ValidateAsNotEmptyErrorMessage"=>"Please enter your daytime phone number.",
"LABEL"=>$registrationfields['businessphone']
));
$registration->AddInput(array(
"TYPE"=>"text",
"NAME"=>"eveningphone",
"ID"=>"eveningphone",
"TABINDEX"=>19,
"SIZE"=>30,
"MAXLENGTH"=>30,
"ValidateOnlyOnServerSide"=>1,
"ValidateRegularExpression"=>"^[0-9]{3}([- \.])?[0-9]{3}([- \.])?[0-9]{4}$",
"ValidateRegularExpressionErrorMessage"=>"Please enter a valid 10 digit phone number.",
//"ValidateAsDifferentFrom"=>"businessphone",
//"ValidateAsDifferentFromErrorMessage"=>"You must enter in at least one contact phoner number."
//"ValidateAsNotEmpty"=>1,
//"ValidateAsNotEmptyErrorMessage"=>"Please enter your evening phone number.",
"LABEL"=>$registrationfields['eveningphone']
));