2

I'm trying to mark required (and empty inputs) like this

input:required {
  border: 1px solid green;
}
input[value=""]:required {
  border: 1px solid red;
}
<input type="text" value="" required>

<input type="text" value="Not empty" required>

It seems to work, but once you set a value to the input, it still marked

3
  • 1
    I think It is not possible by pure css. Commented Nov 30, 2015 at 15:19
  • I think it's answered here: stackoverflow.com/questions/16952526/… Commented Nov 30, 2015 at 15:21
  • 1
    See my answer here. Commented Nov 30, 2015 at 15:25

1 Answer 1

0

If you dont mind using JavaScript you could use an if-statement to give a class based on whether or not the input contains text. then use you CSS on those classes.

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

2 Comments

I know, that way it would be done a while a go, but just curious why i doesnt work
now Im curious too..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.