Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions

Custom form with custom validation


Reply

3 Posts   1179 Views

Avatar
Jatinder

25 August 2010 at 2:19pm Community Member, 23 Posts

Hello,

I am implemented a custom form with a custom template and it works fine.

Besides other fields, the form has two phone number fields. I need to implement a validation "Input at least one phone number".

How do I go about this?

Thanks,
Jatinder

Avatar
Jatinder

26 August 2010 at 4:56pm Community Member, 23 Posts

Would appreciate some help. Please respond!

Avatar
patjnr

26 August 2010 at 7:38pm Community Member, 101 Posts

Hi

Hope this will help you

function submit($data, $form) {
   
      
      
      if(empty($data['tel_1']) && empty($data['Tel_2'] ) ) {
         $form->addErrorMessage("tel_1",_t("ContactForm.TELEPHONEERROR","Please enter at least one Tel number."),"bad");
         // Load errors into session and post back
         Session::set("FormInfo.Form_ContactForm.data", $data);
         return Director::redirectBack();
         
      }

this should work

PAt