I've got an event registration form that I've customized putting Jquery into a custom .tpl override file. It's all working fine, except I'm not sure how to go about adding a custom validation rule. I don't want to override any of the existing validation, I just want to add an extra rule. However, I'm not sure exactly how I should implement this.

I've found this post (https://civicrm.org/comment/6311) but that seems to apply to adding validation rules for ALL forms, and involves editing core files, which I don't want to do.

Do I have to create the whole form from scratch using a plugin? Or can I just add validation javascript to the tpl file?

And yes I know Webforms would be able to handle this, but this system is on Joomla so Webforms is not an option :-)

1 Answer 1


More straight-forward way is to write a simple validateForm hook - https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_validateForm/ into an extension.

If you are new to creating an extension, this might be a good place to start - https://docs.civicrm.org/dev/en/latest/extensions/civix/

  • Thanks Jitendra, but would I have to rewrite all existing form validation rules in that hook? Or would the hook validation simply be added to the existing validations?
    – minbori
    Oct 25, 2018 at 10:21
  • You just need to add the rule that you want - the existing validation in core won't be affected by it. Oct 25, 2018 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.