Reputation: 120308
How does one make a div/input flash or 'pulse'? Say for example a form field has an invalid value entered?
Upvotes: 1
Views: 5256
Reputation: 57715
With CSS3 something like on this page, you can add the pulsing effect to a class called error
:
@-webkit-keyframes error {
from {
-webkit-transform: scale(1.0);
opacity: 0.75;
}
50% {
-webkit-transform: scale(1.2);
opacity: 1.0;
}
to {
-webkit-transform: scale(1.0);
opacity: 0.75;
}
}
.error {
opacity: 0.75;
-webkit-animation-name: error;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: 10;
}
A YouTube demo if you're not on Safari, Chrome or another browser the above works on. The demo makes use of :hover
to start the animation.
You can add the above class to invalid entries.
For example, this is very simple with the jQuery validation plugin:
$(function() {
$("form").validate();
});
Upvotes: 2