Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An invalid form control with name='' is not focusable

In Google Chrome some customers are not able to proceed to my payment page. When trying to submit a form I get this error:

An invalid form control with name='' is not focusable.

This is from the JavaScript console.

I read that the problem could be due to hidden fields having the required attribute. Now the problem is that we are using .net webforms required field validators, and not the html5 required attribute.

It seems random who gets this error. Is there anyone who knows a solution for this?

like image 639
mp1990 Avatar asked Mar 03 '14 13:03

mp1990


People also ask

How do I fix invalid form control with name is not focusable?

This error can be easily fixed by removing the required attribute from the input field or the textarea tag. You can either remove the HTML markup or use JavaScript to remove the required attribute if you are using any form creation libraries.

Is an invalid form control is not focusable?

A form control may not be focusable at the time validation is triggered for several reasons. The two scenarios described below are the most prominent causes: The field is irrelevant according to the current context of the business logic.


1 Answers

This issue occurs on Chrome if a form field fails validation, but due to the respective invalid control not being focusable the browser's attempt to display the message "Please fill out this field" next to it fails as well.

A form control may not be focusable at the time validation is triggered for several reasons. The two scenarios described below are the most prominent causes:

  • The field is irrelevant according to the current context of the business logic. In such a scenario, the respective control should be disabled or removed from the DOM or not be marked with the required attribute at that point.

  • Premature validation may occur due to a user pressing ENTER key on an input. Or a user clicking on a button/input control in the form which has not defined the type attribute of the control correctly. If the type attribute of a button is not set to button, Chrome (or any other browser for that matter) performs a validation each time the button is clicked because submit is the default value of a button's type attribute.

To solve the problem, if you have a button on your page that does something else other than submit or reset, always remember to do this: <button type="button">.

like image 176
Igwe Kalu Avatar answered Sep 22 '22 10:09

Igwe Kalu