New on HTML5 there's an invalid event, to which you can add a listener:
document.addEventListener('invalid', function(e){
var element = $(e.target);
element.addClass(invalid);
element.parent().addClass(invalid);
}, true);
Please note, this event just works when submitting the form... If I style the input
input:invalid { background: red }
, the style is applied when the user starts typing and his input is not valid. Is that event only fired on submit? I tried adding the listener to the inputs themselves instead of the document and it didn't work.I add a listener in order to apply a style to the input's parent... Now, when the user corrects it, it's valid again... I know there's not a valid event, so, how can I accomplish it?
Ok, so here's a fiddle --> http://jsfiddle.net/Osoascam/ceArQ/7/
The invalid listener seems to be only fired on submit... I just wanted to know whether there's a way to add a handler just like there is for focus. See that if you type a
Thanks in advance,
Óscar