Topic: validation and hidden fields in a form
dwilbur priority asked 2 years ago
it is unclear to me what is the proper way to deal with form fields that i want to hide...
- hidden fields based on choices made in the form so far:
for example lets say there is a pulldown and based on which choice in the pulldown it changes what fields are visible for the form.
- validation, and ignoring a hidden field:
if a form field is marked as hidden does the validator automatically ignore it?
- visibility vs hidden:
is there a difference? and if so what?
the documentation that i have read so far doesn't really seem to address this.
Grzegorz Bujański staff answered 2 years ago
We do not describe it in our documentation. If you hide inputs, they are still validated and required by default. This is the default behavior of validation in JS. It doesn't matter if the input is visible or not, if it has the required
attribute added it is still validated.
The simplest solution is to add and remove the required
attribute from the input using JS, depending on whether it is visible or not.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 5.0.0
- Device: na
- Browser: na
- OS: na
- Provided sample code: No
- Provided link: No