Check out these two scripts in Firefox or Chrome. In this , I have a simple form with the required attribute and a submit button. Pressing "send" when the field is empty causes its invalid style (in Firefox, this is a red outline). But he waits until you press the submit button to show that it is invalid.
Now try this one . This is identical, except that there are some css:
input:invalid{ border-color:orange }
With the exception of this time, the color of the orange border is applied even if you press to . So if and only if you manually set the invalid style for the form, the browser applies it earlier, which is not an intuitive behavior. Of course, the required field will be invalid before you enter anything.
Is there any way to fix this?
J-bob source share