One thing is your method name and other is your field name. If the name of
your field is company and your method is company so:

rules:{
    company:{
         company:true
    }
}

Maybe is better rename your method to not confuse.


On Thu, Oct 22, 2009 at 13:24, JMan <jbeck...@gmail.com> wrote:

>
> Still no go... below is my code. I just want to pop a dialog to ask
> the user if they are sure they want to leave the company name blank.
> The field is not required. I thought it would be easier than this? I
> can't get teh addMethod to work or fire at all on validation.
>
>
> //validates the form
>                var validator = frmSubmittal.validate({
>                                                         debug: false,
>                                                        focusCleanup: false,
>                                                        focusInvalid: false,
>                                                        onfocusout: false,
>                                                        onkeyup: false,
>                                                        errorPlacement:
> function(error, element) {error.prependTo
> ( element.parents("div.ctrlHolder"));},
>                                                        errorElement:'div',
>
>  errorClass:'valerror',
>                                                        rules: {
>
>  restitutionaddress: {required: "#sameAsBusinessAddress
> [checked='false']"},
>
>  restitutioncity: {required: "#sameAsBusinessAddress
> [checked='false']"},
>
>  restitutionstate: {required: "#sameAsBusinessAddress
> [checked='false']"},
>
>  restitutionzipcode: {required: "#sameAsBusinessAddress
> [checked='false']"},
>
>  company:true
>                                                                 }
>
>                });
>
>                $.validator.addMethod( "company", function(value, element)
> {alert
> ("hello"); return false;}, "Enter a Company Name" );
>
>
>
>
>
>
> On Oct 21, 9:18 pm, Leonardo K <leo...@gmail.com> wrote:
> > U need set the rules for your validation:
> >
> > frmSubmittal.validate({
> >     debug: false,
> >     focusCleanup: false,
> >     focusInvalid: false,
> >     onfocusout: false,
> >     onkeyup: false,
> >     errorPlacement: function(error, element) {
> >         error.prependTo( element.parents("div.ctrlHolder"));
> >     },
> >     errorElement:'div',
> >     errorClass:'valerror',
> >     rules:{
> >         nameField:{
> >             company:true
> >         }
> >     }
> >
> > });
> > On Wed, Oct 21, 2009 at 22:04, JMan <jbeck...@gmail.com> wrote:
> >
> > > what am I doing wrong here? I cannot figure out how to use the
> > > addMethod().
> >
> > > var frmSubmittal = $("#frmSubmittal");
> >
> > > //validates the form
> > > frmSubmittal.validate({
> > >                                                        debug: false,
> > >                                                        focusCleanup:
> false,
> > >                                                        focusInvalid:
> false,
> > >                                                        onfocusout:
> false,
> > >                                                        onkeyup: false,
> > >                                                        errorPlacement:
> > > function(error, element) {error.prependTo
> > > ( element.parents("div.ctrlHolder"));},
> > >
>  errorElement:'div',
> >
> > >  errorClass:'valerror'
> >
> > > });
> >
> > > $.validator.addMethod( "company", function(value, element) {alert
> > > ("hello"); return false;}, "Enter a Company Name" );
>

Reply via email to