how does one make a div/input flash or 'pulse' say for example a form field has an invalid value entered?
+2
A:
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();
});
jsFiddle example
Peter Ajtai
2010-10-01 02:04:23
@peter, ah very good. I couldn't find one to make the element flash -- do you know of any examples of that?
hvgotcodes
2010-10-01 02:12:58
@hvgotcodes - jQuery has some [ **simple form validation options** ](http://docs.jquery.com/Plugins/validation). Combine that with the technique above. I edited in a simplified example.
Peter Ajtai
2010-10-01 02:15:50
@peter, not using jquery -- its amazing google wont show me some 'flash' enabled by webkit...
hvgotcodes
2010-10-01 18:01:09