admin管理员组文章数量:1410724
I am trying to get around the:
An invalid form control with name='dob_mm' is not focusable.
Error that es in Chrome. Yes, we have a bunch of fields that are required, and yes, these fields are hidden. The form is broken out into tabs, which only one show at a time.
Is there some type of Jquery function that can show some type of popup saying "you must fill out the information in the other tabs"?
I look here but didn't tell me much.
I am trying to get around the:
An invalid form control with name='dob_mm' is not focusable.
Error that es in Chrome. Yes, we have a bunch of fields that are required, and yes, these fields are hidden. The form is broken out into tabs, which only one show at a time.
Is there some type of Jquery function that can show some type of popup saying "you must fill out the information in the other tabs"?
I look here but didn't tell me much.
Share Improve this question edited Jun 17, 2021 at 8:59 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Mar 3, 2013 at 0:01 greycodegreycode 1136 silver badges16 bronze badges 1- how can a hidden input be given property required? Validate it with script instead – charlietfl Commented Mar 3, 2013 at 1:25
1 Answer
Reset to default 11You should do your own validation but as a backup there is a workaround to prevent against these errors in Chrome.
The basic method is this:
- In the submit button click event detect which field failed the browser validation using the
:invalid
pseudo-class that Chrome adds to the field with the error. - Find that field's parent container (eg the tab it's on) and make that container visible.
This will ensure that the user is directed to the tab with the error and Chrome's validation will not fail because the field will be focusable.
A very basic version is something like this:
$('#inputbutton').click(function(){
//find the invalid field
$('#myform').find(':invalid').first()
//find it's parent tab and show it
.parents('.tab-pane').show();
});
本文标签: javascriptForm Control Fault WorkaroundStack Overflow
版权声明:本文标题:javascript - Form Control Fault Workaround - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745013185a2637675.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论