Jorn,

 

One thing I’d like to see is a way to reset a specific field’s error status.
I wrote this as a hack:

 

                                    // for any input field in the signup
form, add a onfocus event

                                    $("#frmSignUp input").focus(

                                                // everything in this
function is executed

                                                function (){

                                                            // $(this)
performs the operation on the current jQuery object

 

                                                            // this removes
the error class from the field

 
$(this).removeClass("error");

 

                                                            // the label
name is equal to the field "name" attribute

                                                            // for checkbox
and radio elements and equal to the "id"

                                                            // attribute for
all other fields

                                                            var sLabelName =
($(this)[0].type == "checkbox" || $(this)[0].type == "radio") ?
$(this)[0].name : $(this)[0].id ;

 

                                                            // remove the
error message for the current field

                                                            $("[EMAIL 
PROTECTED]"
+ $(this)[0].name + "[EMAIL PROTECTED]").html("");

                                                }

                                    );

 

Also, maybe this has changed in beta 2, but I’d think using the ID attribute
for some fields and the NAME attribute for others is confusing for the error
labels. I’d rather see the use of just the NAME attribute—so it’s consistent
across the board.

 

-Dan

 

  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jörn Zaefferer
Sent: Sunday, March 18, 2007 5:38 PM
To: jQuery Discussion.
Subject: [jQuery] Release: Validation plugin beta 2

 

The validation plugin beta 2 is out! If you are already working with it: A
update is recommended. If not, and you need client-side validation (pure or
mixed with AJAX requests), check it out:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Recent changes:

*       Improved dependecy feature by adding two custom expressions:
":blank" to select elements with an empty value and ":filled" to select
elements with a value, both excluding whitespace
*       Added a resetForm() method to the validator: Resets each form
element (using the form plugin, if available), removes classes on invalid
elements and hides all error messages
*       Fixed docs for validator.showErrors()
*       Fixed error label creation to always use html() instead of text(),
allowing arbitrary HTML passed in as messages
*       Fixed error label creation to use specified error class

Have fun!



-- 
Jörn Zaefferer
 
http://bassistance.de
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to