Description
**** ISSUE ****
The implementation 'lastElement' causes unpredictable results when validating empty fields. The interaction of cleared prior error messages further complicates. Finally, a successfully validated field (successList) does not receive the same frequency of validation as a previously invalidated field.
**** STEPS TO REPRODUCE ****
Use as an example the 'Remember The Milk' Form:
http://jquery.bassistance.de/validate/demo/milk/
- Tab or click into 'First Name' field. Enter text.
- Tab once or click into 'Last Name' field. Enter text.
- Shift-tab once or click into 'First Name' field. Clear text.
- Tab once or click into 'Last Name' field. Clear text.
**** EXPECTED RESULT ****
First Name and Last Name fields show invalid state.
**** ACTUAL RESULT ****
First Name shows valid state. Last Name shows invalid state.
**** OTHER USE CASES ****
I first really noticed this issue when validating a pre-filled (and then reloaded, as in a later edit of a profile) form. Fields that begin their life filled, even though they have passed the 'success' test and then been formatted accordingly, can have contents deleted and still visually appear valid.
**** COMMENTS ****
Looking at the code, I'm not certain what the intent was with 'lastElement', so I'm probably not the right party to make related adjustments. It appears to have been added to address a very specific issue. I also don't understand the intended difference between submitted[] and errorMap[], and some related topics.
I might recommend merely replacing the 'lastElement' check with a 'successList' membership check on keyup and focusout. If you want me to make that change, just shoot me an e-mail.
Shannon