Support

Home Forums Event Espresso Premium EE4 From Custom Validation Continued – prevent submission w/ error

EE4 From Custom Validation Continued – prevent submission w/ error

Posted: January 13, 2020 at 11:26 am

Viewing 4 reply threads


Matt Sayre

January 13, 2020 at 11:26 am

We are running a form that needs custom validation. We are referencing the overall solution noted here https://eventespresso.com/topic/ee4-custom-validation/

Question: how do you prevent a form from submitting if there is a custom validation items error?


Matt Sayre

January 13, 2020 at 11:26 am

We are running a form that needs custom validation. We are referencing the overall solution noted here https://eventespresso.com/topic/ee4-custom-validation/

Question: how do you prevent a form from submitting if there are custom validation items not validated?


Josh

  • Support Staff

January 13, 2020 at 3:15 pm

Hi,

May I ask what kind of custom validation are we talking about? For example is it a character limit or a restriction to use a specific type of character for input?


Matt Sayre

January 13, 2020 at 3:47 pm

Hi Josh, the short answer is that we are simply checking to confirm that the question/field has been answered.

The longer explanation is that we are doing conditional logic show/hide and ran in to trouble in the scenario of “required” fields (as defined in EE) that were still hidden.


Matt Sayre

January 14, 2020 at 10:46 am

Hi Josh,

Any guidance on how we can approach this?

Thank you,
Matt


Josh

  • Support Staff

January 14, 2020 at 10:57 am

Hi Matt,

I can advise to set any of the fields to optional that could be conditionally hidden. Then, you can add a bit of JavaScript to your custom JavaScript that adds a “required” class to the field only when it’s displayed. In other words, if the field is shown, then require it. Otherwise don’t require it.

Here’s a quick codepen demo that shows how that can work:

https://codepen.io/joshfeck/pen/MWYXzWd

Viewing 4 reply threads

The support post ‘EE4 From Custom Validation Continued – prevent submission w/ error’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso