Ahhh...Thanks Karl! That worked..
:) Mandy On 5/16/07, Karl Rudd <[EMAIL PROTECTED]> wrote:
Put quotes (double or single) around the name: "intro-currentFirstName": "Please enter a valid email" Technically/ideally that's what all the "keys" should be list as they are strings. It's just an allowed "shortcut" to leave off the quotes. Karl Rudd On 5/16/07, Mandy Singh <[EMAIL PROTECTED]> wrote: > This script does not work for me when I have a "-" in my rules > > > $(document).ready(function() { > $.validator.setDefaults({ > debug: true > }); > > var container = $('div.container'); > // validate the form when it is submitted > $("#form1").validate({ > errorContainer: container, > errorLabelContainer: $("ol", container), > wrapper: 'li', > rules: { > intro-currentFirstName: { required:true, email:true }, > phone: { required:true, minLength: 3 }, > address: { required:true,minLength:3 } > }, > messages: { > intro-currentFirstName: "Please enter a valid email", > phone: "Please enter a valid phone", > age: "Please specify your age as a number (at least 3)." > } > //event: "keyup" > }); > }); > The above does not work. > It gives me an error saying missing ":" > > But as soon as I change the field name to introCurrentFirstName instead of > intro-currentFirstName it starts working. > > Any ideas? > > > On 5/16/07, Dan G. Switzer, II <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Exactly! > > > > > > > > -Dan > > > > > > > > > > ________________________________ > > > > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Mandy Singh > > Sent: Tuesday, May 15, 2007 2:06 PM > > To: jquery-en@googlegroups.com > > Subject: [jQuery] Re: Form Validation Plugin > > > > > > > > > > Oh! Didn't know that. Thanks for pointing that out Dan (I am new to jquery > had been using prototype till now). > > > > So, just the packed version of the file is good enough? > > > > And using that I can define the rules such as - $("#myform").validate({ > > > > event: "keyup" > > > > rules: { > > > > firstname: { required: true }, > > > > age: { > > > > required: "#firstname:blank", > > > > number: true, > > > > minValue: 3 > > > > > > > > > > }, > > > > password: { > > > > required: function() { > > > > return $("#age").val() < 18; > > > > }, > > > > minLength: 5, > > > > maxLength: 32 > > > > } > > > > }, > > > > messages { > > > > password: { > > > > required: "Your password is required because you are > not yet 18 years or older." > > > > > > minLength: "Please enter a password at least 5 > characters long.", > > > > maxLength: "Please enter a password no longer then > 32 characters long." > > > > }, > > > > age: "Please specify your age as a number (at least 3)." > > > > > > } > > > > }); > > > > > > > > > > > > On 5/15/07, Dan G. Switzer, II <[EMAIL PROTECTED]> wrote: > > > > > > Mandy, > > > > >I had a look at that before I posted. That does what I want but for > simple > > >validations I can't include 40-50 KB of code (cmforms, meta.js, > > >jquery.validate )...thats an overkill when I just want a required:true > > >check. > > > > > >Any other? > > > > The only thing that is required is jquery.validate.js. The packed version > of > > the file is only 6k. > > > > The meta.js file is only required if you want to define validation rules > > using the class attribute of your tags. > > > > The other libraries are used just for layout in the examples. > > > > -Dan > > > > > > > > > > > > > >