Reputation: 96
See the picture below:
I want to stylize the red box-shadow and for example change the color of it.
EDIT: When we use a code like this:
<input type="text" name="example" required>
if user click on submit button without completing the required box, it alerts! I wanna change default shadow color.
Upvotes: 0
Views: 142
Reputation: 2767
input:invalid {
box-shadow:0 0 0px #f00;
}
will override the shadow.
Note, however, that styles entered here will style any required boxes before the form has been submitted. As such, I suspect you may need to run a javascript on submit which adds a class to the form, so that the styles only appear post-submit. For example, make it so that submitting the form adds a class called "submittedform" to the form and then add the styles.
.submittedform input:invalid {
box-shadow:0 0 0px #f00;
}
(There may be a html5 way of doing this, but I don't think there is)
Upvotes: 2