I have created a form which is split into many "tabs" using jQuery; and the fields which are found in the various tabs.
All the fields in the form have their checks in place, some are required, some must have a minimum value, etc.
However, when I try to submit a form with invalid values in fields, if those fields are under a tab different from the current, I get an error on the console from Google Chrome:
An invalid form control is not focusable
but the user sees no effect, nor can s/he find the wrong field since it has not been highlighted by the browser.
I have already read the answers to the following questions:
- An invalid form control with name='' is not focusable
- "Invalid form control" only in Google Chrome
- An invalid form control with name='' is not focusable. WITHOUT ANY REQUIRED OR HIDDEN INPUTS
However, they all say to give the correct name to the fields (already done) or to remove the "required attribute" (cannot do that, it's there for a reason!).
I would like to underline that I am also doing server side validation, and so this is not the topic of this question.
How can I keep HTML5 validation in the form while at the same time avoiding that error?
EDIT:
Here you can find an example of what I am describing, even though that is much simpler than the actual form, if you load it in Google Chrome and submit the form right away, you'll see the error in your console.
<form id="form_tabs" name="form_tabs" method="post" action="">
<div id="tabs" class="ui-tabs">
<ul>
<li><a rel="tabs" href="#tab1">FIRST TAB</a></li>
<li><a rel="tabs" href="#tab2">SECOND TAB</a></li>
</ul>
<div id="tab1" class="ui-tabs-hide">
<input type="text" name="text1" id="text1" value="" placeholder="I am NOT required"/>
</div>
<div id="tab2" class="ui-tabs-hide">
<input type="text" name="text2" id="text2" value="" placeholder="I REALLY am required!" required="required"/>
</div>
</div>
<br/>
<button type="submit" value="submit">
SEND FORM
</button>
</form>
display:none
– and the browser can not focus a form field inside such a hidden tab. // If you want to use tabs, then you should probably do validation on each tab separately with JS, otherwise I’d say it is rather bad UX to begin with. – CBroe