Title: Form field pattern matching validation
Last modified: November 13, 2022

---

# Form field pattern matching validation

 *  Resolved [exelexys](https://wordpress.org/support/users/exelexys/)
 * (@exelexys)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/)
 * First thanks for creating the most capable Full Site Editor Form Builder!
 * Is there a way to add additional validation (e.g., pattern matching) for fields
   like email address and telephone number? The current validation is helpful, but
   for example, it would be nice to validate email addresses to ensure they have
   a top-level domain.
 * Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Pradnya](https://wordpress.org/support/users/pradnyajegstudio/)
 * (@pradnyajegstudio)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16194614)
 * Hi [@exelexys](https://wordpress.org/support/users/exelexys/)
 * We already have an option for validate telephone number using pattern, but not
   for the email. At the moment, we validate the email only if it has @ and the 
   domain.
 * If you want to add additional validation, there is a way. You can use custom 
   script. This code below will prevent the button submit action and will continue
   the validation form setting and the submit after custom validation is complete.
 *     ```
       <script type="text/javascript">
       	window.addEventListener('DOMContentLoaded', function(event) {
       		document.querySelector('.guten-your_button_id button.gutenverse-input-submit').addEventListener("click", function(e) {
       			e.preventDefault();
       			var customValidate = true;
   
       			// Your custom validation
   
       			if (customValidate) {
       				document.querySelector('.guten-form-builder.guten-your_form_id').dispatchEvent(new CustomEvent("submit", { cancelable: true }));
       			}
       		});
       	});
       </script>
       ```
   
 * For the id, you can get it from the blocks.
    [https://prnt.sc/IC476gbVrNJE](https://prnt.sc/IC476gbVrNJE)
   [https://prnt.sc/MlNBv9m6-9nA](https://prnt.sc/MlNBv9m6-9nA)
 *  Thread Starter [exelexys](https://wordpress.org/support/users/exelexys/)
 * (@exelexys)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16194843)
 * Great. Will try it out.
 * Thanks!
 *  [Pradnya](https://wordpress.org/support/users/pradnyajegstudio/)
 * (@pradnyajegstudio)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16198448)
 * You’re welcome exelexys. Let me know if you still have any questions.
 *  Thread Starter [exelexys](https://wordpress.org/support/users/exelexys/)
 * (@exelexys)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16236191)
 * Having trouble accessing the value of, in this case, the email address field 
   using the event listener you provided.
 * Added class name **join-email-address** to the email field within the form, but
   on submit, the value of:
 * `const email_address = document.getElementsByClassName("join-email-address")[
   0].value;`
    or `var email_address = document.getElementsByClassName("join-email-
   address")[0].value;`
 * is undefined.
 * Any ideas?
 *  [Pradnya](https://wordpress.org/support/users/pradnyajegstudio/)
 * (@pradnyajegstudio)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16239020)
 * Please try using this code
    `var email_address = document.querySelector(".join-
   email-address input").value;`
 *  [Pradnya](https://wordpress.org/support/users/pradnyajegstudio/)
 * (@pradnyajegstudio)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16333972)
 * Hi,
 * I haven’t heard you for a while. I will mark this as resolved. If you still have
   questions, please create another topic.
 * Thank you

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Form field pattern matching validation’ is closed to new replies.

 * ![](https://ps.w.org/gutenverse/assets/icon-256x256.gif?rev=3132408)
 * [Gutenverse - WordPress Blocks, Page Builder & Site Editor](https://wordpress.org/plugins/gutenverse/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gutenverse/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gutenverse/)
 * [Active Topics](https://wordpress.org/support/plugin/gutenverse/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gutenverse/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gutenverse/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Pradnya](https://wordpress.org/support/users/pradnyajegstudio/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/form-field-pattern-matching-validation/#post-16333972)
 * Status: resolved