An invalid form control with name='additional_here_about_other_field' is not focusable.
This code is for a select field with four dropdowns. A couple of the options are to be required: #additional_here_about_other_field
and the #additional_who_is_your_orthodontist_field
. When a required field is selected, you have to enter additional data in another text field that will show/unhide. When you select a required option and then switch to an option which is required or not and try to submit the form, you get the is not focusable error. It seems when you select a required field and then switch to another field, the previous required field although now hidden is still waiting to be validated?
jQuery(document).ready(function () {
if(jQuery("#additional_here_about_other_field").length > 0){
jQuery("#additional_here_about_other_field").hide();
jQuery("#additional_how_did_u_hear_about_harp").change(function(){
if(jQuery(this).val() == 'Other (please specify)'){ jQuery("#additional_here_about_other_field").show().prop('required',true); }
else { jQuery("#additional_here_about_other_field").hide(); }
});
}
if(jQuery("#additional_who_is_your_orthodontist").length > 0){
jQuery("#additional_who_is_your_orthodontist").hide();
jQuery("#additional_how_did_u_hear_about_harp").change(function(){
if(jQuery(this).val() == 'Orthodontist Referral'){ jQuery("#additional_who_is_your_orthodontist").show().prop('required',true); }
else { jQuery("#additional_who_is_your_orthodontist").hide(); }
});
}
});
HTML snippet
<select name="additional_how_did_u_hear_about_harp" id="additional_how_did_u_hear_about_harp" class="select " data-allow_clear="true" data-placeholder="How Did You Hear About The Harp?" >
<option value="" selected='selected'></option>
<option value="Patient" >Patient</option>
<option value="Orthodontist Referral" >Orthodontist Referral</option>
<option value="Trade Show" >Trade Show</option>
<option value="Mailer" >Mailer</option>
<option value="Other (please specify)" >Other (please specify)</option>
</select>
<div class="clear"></div>
<p>
<input type="text" class="input-text " name="additional_here_about_other_field" id="additional_here_about_other_field" placeholder="Other (please specify)" value="" />
</p>
<div class="clear"></div>
<p>
<input type="text" class="input-text " name="additional_who_is_your_orthodontist" id="additional_who_is_your_orthodontist" placeholder="Who is your orthodontist?" value="" />
</p>
<div class="clear"></div>
Just because a form control is hidden doesn't mean it isn't required. And since it is required, but hidden the browser can't focus the form control.
Every place you have .hide()
change it to .hide().prop('required',false)
to fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With