0

I have an input field and now I want to style it in a way so that whenever the input field is empty we need a normal border of black color and on focus need to change to red on filling.

.form-control {
  width: 300px;
  height: 40px;
  margin: 0 auto 0 auto;
  border: 1px solid red;
  border-radius: 3px;
}
<input class="form-control" placeholder="Password" name="password" type={passwordShown ? "text" : "password"} value={formValues.password} onChange={handleChange} />
isherwood
  • 58,414
  • 16
  • 114
  • 157
sai charan
  • 67
  • 2
  • 8

1 Answers1

-1

Try this code:

.form-control {
  width: 300px;
  height: 40px;
  margin: 0 auto 0 auto;
  border: 1px solid #000;
  border-radius: 3px;
 }
.form-control:hover,.form-control:focus {
  border: 1px solid #f00;
}
<input class="form-control" placeholder="Password" name="password" type={passwordShown ? "text" : "password"} value={formValues.password} onChange={handleChange} />
Yash porwal
  • 301
  • 3
  • 9