Conditional section showing with non-validating entry - How can I correct this?

By: Mark Hansen | Asked: 09/06/2024
ForumsCategory: General questionsConditional section showing with non-validating entry - How can I correct this?
Mark HansenMark Hansen asked 3 months ago

Form Basics I have a form with many fields in 3 separate Sections and hide the bottom 2 Sections until the first Section is completed. I feel like I have missed something simple.

Form Section 1:

  • Zipcode - Text with regex validation ^[0-9]{5}$ (Five numbers only)
  • State (dropdown lookup of States data form)
  • Hidden lookup field. 

Once the zip/state are completed, the hidden lookup field populates from another data form related to the State selection and Section 2 of the form is shown to the user.  I have 2 data forms but currently only use the States data:

  • All US Zip Codes (5-digit zip code, State and other data)
  • States (51 entries with all US States and DC, along with other data) I use this for the dropdown, since it's much smaller in size than the Zipcode data form.

Form Section 2 is where all the main data is gathered in many more fields and some of the results for this Section are based on the State value from Section 1. It is hidden with a conditional stating "Hide if Zip is empty", "Hide if State is empty", "Hide if Hiddenfield is empty". This has worked fine as well.

The Problem If a user comes in and enters 212 (or 4590, or any number less than 5 digits) in the zip code field, and populates the State dropdown, the hidden field populates (Based on the State selection) and the section Section 2 shows, regardless of whether the Zip Code field passed validation or not.

Questions you might be able to help with:

  1. Can I restrict Section 2 from showing if the Zip code does not validate?
  2. Can I use a hidden Lookup field that watches the Zipcode text field in Section 1, finds it's matching value in the Zipcode data table, and pulls another bit of data into a the hidden field? (If the zip code is not valid, I would display a message stating "Zip code not found".)

Thanks in advance, and if there is another simple solution, I'm happy to hear it also. Mark      

1 Answers
Rob LeVineRob LeVine answered 2 months ago
For #1 you can accomplish what you want in jQuery. I don't know if anything out-of-the-box where you can conditionally key off validation. For #2 you can also accomplish with jQuery (and Ajax). Since you're keying off validation it's the same issue, though even if it's not, you might not be able to use it without custom code. You can ask Formidable support/sales about it.
Mark HansenMark Hansen replied 2 months ago

Thanks, Rob.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right