• Resolved exelexys

    (@exelexys)


    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

    (@pradnyajegstudio)

    Hi @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/MlNBv9m6-9nA

    Thread Starter exelexys

    (@exelexys)

    Great. Will try it out.

    Thanks!

    Pradnya

    (@pradnyajegstudio)

    You’re welcome exelexys. Let me know if you still have any questions.

    Thread Starter exelexys

    (@exelexys)

    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

    (@pradnyajegstudio)

    Please try using this code
    var email_address = document.querySelector(".join-email-address input").value;

    Pradnya

    (@pradnyajegstudio)

    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.