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


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

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: publish

Updated by  Josh 6 days, 16 hours ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!