The code below works well in Safari but in Chrome and Firefox the form will not submit. Chrome console logs the error An invalid form control with name=\'\' is not fo
I got this error message when I entered a number (999999) that was out of the range I'd set for the form.
<input type="number" ng-model="clipInMovieModel" id="clipInMovie" min="1" max="10000">
It will show that message if you have code like this:
<form>
<div style="display: none;">
<input name="test" type="text" required/>
</div>
<input type="submit"/>
</form>
solution to this problem will depend on how the site should work
for example if you don't want the form to submit unless this field is required you should disable the submit button
so the js code to show the div should enable the submit button as well
you can hide the button too (should be disabled and hidden because if it's hidden but not disabled the user can submit the form with others way like press enter
in any other field but if the button is disabled this won't happen
if you want the form to submit if the div is hidden you should disable any required input inside it and enable the inputs while you are showing the div
if someone need the codes to do so you should tell me exactly what you need
I had the error:
An invalid form control with name='telefono' is not focusable.
This was happening because I was not using the required field correctly, which enabled and disabled when clicking on a checkbok. The solution was to remove the required
attribute whenever the checkbok was not marked and mark it as required when the checkbox was marked.
var telefono = document.getElementById("telefono");
telefono.removeAttribute("required");
replace required
by required="required"
Chrome wants to focus on a control that is required but still empty so that it can pop up the message 'Please fill out this field'. However, if the control is hidden at the point that Chrome wants to pop up the message, that is at the time of form submission, Chrome can't focus on the control because it is hidden, therefore the form won't submit.
So, to get around the problem, when a control is hidden by javascript, we also must remove the 'required' attribute from that control.
$("...").attr("required"); and $("...").removeAttr("required");
didn't work for me until I putted all my jQuery code between that:
$(document).ready(function() {
//jQuery code goes here
});