I'm using Dan G Switzer approach to show error messages. Looks like this:

           // para qualquer campo no form de nome frm adiciona um evento
onfocus
// for any field in your form with name frm adds an onfocus event

            $("#frm input").focus(
                function (){
                    // remove a class de erro do campo
// remove error class to the field
                    $(this).removeClass("error");

                    // para campos checkbox e radio o nome do label deve ser
igual ao nome do campo e igual ao
                    // atributo id para todos os outros campos
// for checkbox and radio fields , label name needs to be equal to the field
                    var sLabelName = ($(this)[0].type == "checkbox" ||
$(this)[0].type == "radio") ? $(this)[0].name : $(this)[0].id ;

                    // oculta a mensagem de erro para o campo atual
// hides error message for the actual field
                    $("[EMAIL PROTECTED]" + $(this)[0].name +
"[EMAIL PROTECTED]").hide();
                }
            );

Cheers
Marco Antonio

2007/9/28, Josh Nathanson <[EMAIL PROTECTED]>:
>
>
> Hi Rick,
>
> That was the first thing I tried, it didn't work.  Then it seemed to say
> in
> the docs that the label element would be created for you, and placed after
> the input field, so I took out the label markup, and that also didn't
> work.
>
> I know I've got the js file included correctly, and it's doing
> *something*,
> because when I set debug = true, the form doesn't submit.
>
> -- Josh
>
>
>
> ----- Original Message -----
> From: "Rick Faircloth" <[EMAIL PROTECTED]>
> To: <jquery-en@googlegroups.com>
> Sent: Friday, September 28, 2007 12:55 PM
> Subject: [jQuery] Re: Validation plugin noob
>
>
> >
> > Hi, Josh...
> >
> > In your HTML, did you specify a place for the error
> > message to appear?
> >
> > This is from Jorn's example:
> >
> > <label for="firstname">Firstname</label>
> > <input id="firstname" name="firstname" />
> >
> > I handle my error messages a little different than the
> > example above, preferring my error messages above the input field.
> >
> > If I'm not mistaken I believe you're going to need a <label... field
> > for the default messages to appear.
> >
> > Hopefully someone will come along who can tell you for sure.
> >
> > But check's Jorn's source on:
> >
> > http://jquery.bassistance.de/validate/demo-test/
> >
> > And it may give you some clues about how the HTML works.
> >
> > Rick
> >
> >
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
> > Behalf Of Josh Nathanson
> > Sent: Friday, September 28, 2007 3:18 PM
> > To: jquery-en@googlegroups.com
> > Subject: [jQuery] Validation plugin noob
> >
> >
> > Hey all,
> >
> > Using Jorn's Validation plugin, it's not displaying the error
> message.  I
> > must be missing something obvious.  I'm just trying a test - it seems
> like
> > when I submit, if the field is empty, it should display an error message
> > after the input field.  What am I doing wrong?
> >
> > JS:
> > $("#editform").validate({
> >  rules: {
> >    FirstName : "required"
> >    },
> >  messages: {
> >    FirstName : "Please enter your first name."
> >    },
> >  debug: true
> > });
> >
> > Markup:
> > <input type="Text" size="30" name="FirstName" id="FirstName" value=""
> > class="formfield" maxlength="50">
> >
> > -- Josh
> >
> >
> >
>
>

Reply via email to