1

I have a form on a website with input with the required attribute.

When the required attribute is actived on Firefox (when user do't fill correcty the form), there is a kind of red border on my input.

I would like to know how can I change that ? I can I manipulate the style of the required effect when it is activated ?

Thanks for you answers !

xdxp
  • 61
  • 1
  • 1
  • 4

2 Answers2

0

You can control it by :valid and :invalid Pseudo class.

 input:valid {
      border: 1px solid green;
      outline: none;
    }
    
    input:invalid {
      border: 1px solid red;
      outline: none;
    }
<input type="text" required />
Sankar
  • 6,908
  • 2
  • 30
  • 53
0

You use two pseudo-selectors in combination: :required:invalid and :required:valid

For example:

input[type=text]:required:invalid { border-color: red; }

Robert
  • 6,881
  • 1
  • 21
  • 26