1

formNoValidate button attribute still triggers :user-invalid CSS class

Although it does not require validation it still triggers the class. Is there a non-javascript way of solving this problem?

1
  • 1
    There is no non-javascript way as the :user-invalid pseudo-class is tied to the browser's validation state, not submission behavior, so even with the formNoValidate attribute, invalid fields will still trigger :user-invalid. What you can do is minimize its impact using CSS to style :user-invalid and make it less noticeable. Commented Apr 8 at 18:48

1 Answer 1

0

No, there is not a CSS only solution. The :user-invalid class is still applied even if the submit button has formNoValidate which is because CSS does not consider button attributes in styling.

The best workaround that still rquires JS is to use JS to add a class to the form when submitting a formNovalidate button and then override the style based on that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.