ChronoEngine.com homepage

FAQs

How can I run Auto and Custom Serverside Validation together?

Written
Running either Auto Serverside Validation or Custom Serverside Validation separately is straightforward. But if you want to use both then adding Event Loops means that the second one will only be run if the first one finds no errors. Here is a way to link them together.
Put the Auto Serverside Validation action first in the On Submit event. Leave both the On Success and On Fail events empty.
Next add the Custom Serverside Validation action and add your test code using the code structure shown in this FAQ under 'Running Several Validation':
<?php
if ( !test_1 ) {
  $form->validation_errors['input_1'] = "Add message 1 here";
}
if ( !test_2 ) {
  $form->validation_errors['input_2'] = "Add message 2 here";
}  
if ( !test_3 ) {
  $form->validation_errors['input_3'] = "Add message 3 here";
}
if ( isset($form->validation_errors) && count($form->validation_errors) > 0 ) {
  return false;
}
?>
This will check the errors from both validation actions.
Add the Event Loop action to the On Fail event of this action.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com