jquery validate: focusCleanup: true and focusInvalid: false don't work as expected
Posted
by laramichaels
on Stack Overflow
See other posts from Stack Overflow
or by laramichaels
Published on 2010-01-19T05:35:02Z
Indexed on
2010/05/09
11:48 UTC
Read the original article
Hit count: 620
I am using Joern's jquery validation plugin 1.6.
My goal is to have the following behavior: remove the error message for an element once the user focuses it. From what I understand setting 'focusCleanup: true' should take care of this.
However (at least on my browser (Firefox 3.5.7 on Linux)), I only get the desired behavior (ie, error message for a field disappearing once you focus it) if I click into the field; it doesn't handle tabbing into the field correctly.
Sample code:
HTML:
<form id='abc' name='abc'>
<input type="text" id="t1" name="t1"/>
<input type="text" id="t2" name="t2"/>
<input type="submit" id="submit" value='submit'/>
</form>
JS:
$("#abc").validate({
focusCleanup: true,
focusInvalid: false,
rules: {t1: {required: true, email:true}, t2: {required: true,email:true}}
});
I am setting 'focusInvalid: false' because the docs say one should avoid combining focusCleanup and focusInvalid; in my experience commenting out that line makes no difference.
Am I doing something wrong?
© Stack Overflow or respective owner