Answers.Body: <p>The controller you're posting to is responsible for the validation. In the case of the <code>entries/saveEntry</code> controller for example there's an Entry model populated and then run through the validation. Each model attribute and all the fields (content) have to give their ok for the complete model to validate correctly.</p>
  
  <p>For the fields it's the field type's attribute type and an optional <code>validate</code> method that are responsible. Have a look at this plugin by Marion Newlevant, it provides a simple field type with configurable validation and is probably a good example for what you're trying to achieve.</p>
  
  <p><a href="https://github.com/marionnewlevant/craft-mn_matchinput" rel="nofollow">https://github.com/marionnewlevant/craft-mn_matchinput</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-19T11:25:29.543Z
Answers.Text: Hi CarlCS, thanks for guiding me. I installed the MNmatchInput plugin and the concept is what I am looking for. It has now added a new level of complexities. The plugin works. I am unsure of how to get the new fieldtype to display on my front-end form. When I use the codeBlock from my previous message all the other fields display except the "matchInput" fieldType. If I call it up directly using something like this "fieldLayout.getFieldLayout().getFields()" I lose all validation and the form sends the email with a blank email field. If you could please assist It would deeply be appreciated.
Answers.UserDisplayName: Gevann Mullins
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-19T11:48:59.663Z
Answers.Text: Sorry, can't really assist as I've never used a plugin like formbuilder and always build the forms manually, similar to how it's described in the Craft documentation https://craftcms.com/docs/templating/entry-form
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-20T08:57:16.080Z
Answers.Text: Thanks for assisting me tho. I've actually just gone ahead and created my forms manually. Read through most of the documentation that you suggested and understand have a better understanding of how to build the forms from scratch. I've discovered that this gives me a better understanding of the mechanics of craft. Who knows, maybe in the future I might built a plugin to simplify building forms for craft.
Answers.UserDisplayName: Gevann Mullins
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-20T09:02:48.297Z
Answers.Text: That's great, Gevann. Do your fields use the validation rules and return error messages how you'd like them to do? Everything solved (except your custom plugin part, hehe)?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-20T11:56:52.820Z
Answers.Text: For now the fields are using basic validation rules and it returns error messages that I can deal with. I would like to get more into detailed validation as time goes on but I am happy with the results I have for now. It takes up a bit of my time as I am still learning craft but I want to get this project over and done with. When I have some free time I can do all the nitty gritty things.
Answers.UserDisplayName: Gevann Mullins
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-19T05:06:58.900Z
Answers.LastActivityDate: 2016-05-19T05:06:58.900Z
Answers.UserDisplayName: carlcs
Body: <p>I am relatively new to Craft CMS and have been using the formBuilder2 plugin to create forms. No problem this far. I have been able to use ElementApi to output the forms into Json. Still no problem.
  My issue starts when I have to add validation to my form fields. I have read the "The Definitive Guide to Craft Validation for Plugin Developers (The Book)" and I am still very much confused as to how I actually implement validation on specific field in my form. In a nutshell, how can I add a email validator to an field that I named email. Also, how do I implement this to the fieldset if all I have to go with is:</p>
  
  <pre><code>        {% set fields = tab.getFields() %}
          &lt;fieldset class="{{ tab.name |lower|replace(' ', '-') }}"&gt;
              &lt;legend&gt;{{ tab.name }}&lt;/legend&gt;
              {% for field in fields %}
              {% set input = craft.formBuilder2.getInputHtml(field) %}
              {{ input | raw }}
              {% endfor %}
          &lt;/fieldset&gt;
          {% endfor %}
  </code></pre>
  
  <p>Not to sound silly but why, why, why why????
  Please can someone help me....</p>
  
Tags: <field><custom-fieldtype><validation><custom-field>
Title: Form field validation
ThreadText: # Form field validation
  
  (Asked by: username_0 on 2016-05-18)
  
  I am relatively new to Craft CMS and have been using the formBuilder2 plugin to create forms. No problem this far. I have been able to use ElementApi to output the forms into Json. Still no problem.
  My issue starts when I have to add validation to my form fields. I have read the "The Definitive Guide to Craft Validation for Plugin Developers (The Book)" and I am still very much confused as to how I actually implement validation on specific field in my form. In a nutshell, how can I add a email validator to an field that I named email. Also, how do I implement this to the fieldset if all I have to go with is:
  
  ```
          {% set fields = tab.getFields() %}
          <fieldset class="{{ tab.name |lower|replace(' ', '-') }}">
              <legend>{{ tab.name }}</legend>
              {% for field in fields %}
              {% set input = craft.formBuilder2.getInputHtml(field) %}
              {{ input | raw }}
              {% endfor %}
          </fieldset>
          {% endfor %}
  
  ```
  
  Not to sound silly but why, why, why why????
  Please can someone help me....
  
  **Tags:** field, custom-fieldtype, validation, custom-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-19. Score: 1
  
  The controller you're posting to is responsible for the validation. In the case of the `entries/saveEntry` controller for example there's an Entry model populated and then run through the validation. Each model attribute and all the fields (content) have to give their ok for the complete model to validate correctly.
  
  For the fields it's the field type's attribute type and an optional `validate` method that are responsible. Have a look at this plugin by Marion Newlevant, it provides a simple field type with configurable validation and is probably a good example for what you're trying to achieve.
  
  <https://github.com/marionnewlevant/craft-mn_matchinput>
  
  > **Comments:**
  > **username_0**: Hi CarlCS, thanks for guiding me. I installed the MNmatchInput plugin and the concept is what I am looking for. It has now added a new level of complexities. The plugin works. I am unsure of how to get the new fieldtype to display on my front-end form. When I use the codeBlock from my previous message all the other fields display except the "matchInput" fieldType. If I call it up directly using something like this "fieldLayout.getFieldLayout().getFields()" I lose all validation and the form sends the email with a blank email field. If you could please assist It would deeply be appreciated.  
  > **username_1**: Sorry, can't really assist as I've never used a plugin like formbuilder and always build the forms manually, similar to how it's described in the Craft documentation https://craftcms.com/docs/templating/entry-form  
  > **username_0**: Thanks for assisting me tho. I've actually just gone ahead and created my forms manually. Read through most of the documentation that you suggested and understand have a better understanding of how to build the forms from scratch. I've discovered that this gives me a better understanding of the mechanics of craft. Who knows, maybe in the future I might built a plugin to simplify building forms for craft.  
  > **username_1**: That's great, username_0. Do your fields use the validation rules and return error messages how you'd like them to do? Everything solved (except your custom plugin part, hehe)?  
  > **username_0**: For now the fields are using basic validation rules and it returns error messages that I can deal with. I would like to get more into detailed validation as time goes on but I am happy with the results I have for now. It takes up a bit of my time as I am still learning craft but I want to get this project over and done with. When I have some free time I can do all the nitty gritty things.  
  
  ---
  
  