Answers.Body: <p>More straight-forward way is to write a simple <code>validateForm</code> hook - <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_validateForm/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_validateForm/</a> into an extension.</p>
  
  <p>If you are new to creating an extension, this might be a good place to start - <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/extensions/civix/</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-25T10:21:55.580Z
Answers.Text: 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?
Answers.UserDisplayName: minbori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-25T10:46:21.303Z
Answers.Text: You just need to add the rule that you want -  the existing validation in core won't be affected by it.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-25T08:53:39.940Z
Answers.LastActivityDate: 2018-10-25T08:53:39.940Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>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.</p>
  
  <p>I've found this post (<a href="https://civicrm.org/comment/6311" rel="nofollow noreferrer">https://civicrm.org/comment/6311</a>) but that seems to apply to adding validation rules for ALL forms, and involves editing core files, which I don't want to do. </p>
  
  <p>Do I have to create the whole form from scratch using a plugin? Or can I just add validation javascript to the tpl file?</p>
  
  <p>And yes I know Webforms would be able to handle this, but this system is on Joomla so Webforms is not an option :-)  </p>
  
Tags: <civievent><forms><validation>
Title: how to add custom validation rules to civievent registration form
ThreadText: # how to add custom validation rules to civievent registration form
  
  (Asked by: username_0 on 2018-10-25)
  
  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 :-)
  
  **Tags:** civievent, forms, validation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-25. Score: 1 | Accepted answer
  
  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/>
  
  > **Comments:**
  > **username_0**: Thanks username_1, 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?  
  > **username_1**: You just need to add the rule that you want -  the existing validation in core won't be affected by it.  
  
  ---
  
  