validations

Permalink 1 user found helpful
I am using form helper class to make a form for block admin interface.

I want to implement javascript(client side validations) for the fields.I looked at the class but i didn't find any function for validation.

So can someone point me where should I look for that?

Thanks in advance.

 
jasteele12 replied on at Permalink Best Answer Reply
jasteele12
Been quite a while since you asked, but are you asking about something like this (not tested)?

In /blocks/your_block/controller.php:
class YourBlockBlockController extends BlockController (
   ...
   public function getJavaScriptStrings() {
      return array(
         'id-required' => t('You must enter an ID.'),
         'pin-required' => t('You must enter a PIN number.')
      );
   }
}


In /block/your_block/auto.js:
ccmValidateBlockForm = function() {
   if ($('#id-number').val() == '' || $('#id-number').val() == 0) {
      ccm_addError(ccm_t('id-required'));
   }
   if ($('#pin-number').val() == '' || $('#pin-number').val() == 0) {
      ccm_addError(ccm_t('pin-required'));
   }
   return false;
}
sam12345 replied on at Permalink Reply
I already got it bro though thanks for your efforts.

Keep rocking!!!