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   1224 Views

Avatar
Jatinder

Community Member, 23 Posts

25 August 2010 at 2:19pm

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

Community Member, 23 Posts

26 August 2010 at 4:56pm

Would appreciate some help. Please respond!

Avatar
patjnr

Community Member, 101 Posts

26 August 2010 at 7:38pm

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