Here is an interesting way to do it.  In my case, I was using a main
error div at the top of the page, so I didn't need the individual
label.error elements inline.  They kept showing up no matter what I
did until I added this to my validation:

errorElement: "em"

This changes the element that the errors are displayed in from label
to em.  I am not using any em elements on my page, so the error
messages just don't show up (except the main one, which I want to show
up).

jQuery.validator.messages.required = "";
                $('#member_form').validate({
                        //change error element
                        errorElement: "em",
                        //use main error div instead
                        invalidHandler: function(e, validator) {
                                var errors = validator.numberOfInvalids();
                                        if (errors) {
                                                var message = errors == 1
                                                        ? 'You missed 1 field. 
It has been highlighted below'
                                                        : 'You missed ' + 
errors + ' fields.  They have been
highlighted below';
                                                $("div.error 
span").html(message);
                                                $("div.error").show();
                                        } else {
                                                $("div.error").hide();
                                        }
                                },

                        rules: {
                                username: {
                                        required: true,
                                        email: true
                                        },
                                password: {
                                        required: true,
                                        minlength: 4,
                                        maxlength: 10
                                        },
                                password_confirm: {
                                        required: true,
                                        equalTo: "#password",
                                        minlength: 4,
                                        maxlength: 10
                                        },
                                accept_terms: "required",
                                cf_member_fname: "required",
                                cf_member_lname: "required",
                                cf_member_city: "required",
                                cf_member_country: "required",
                                captcha: "required"
                          }

                });

On Apr 10, 8:08 pm, Rick <r...@marketingease.com> wrote:
> I'm using this plugin in its simplest 
> form..http://docs.jquery.com/Plugins/Validation
>
> All I have is this for my code:
>
> <script>
> $(document).ready(function(){
>         $("#form").validate();});
>
> </script>
>
> It works fine, but I'm trying to hide the error messages which it
> defaults to "This field is required." The error message shows up in a
> label..
>
> How in the world do I hide those error messages within those labels???
> I'm sure it's easy, but I cannot find any examples anywhere!!
>
> Thanks to whoever helps out..

Reply via email to