On Nov 29, 11:06 pm, deronsizemore <[EMAIL PROTECTED]> wrote: > > The code is as follows: > > jQuery.validator.addMethod("lettersonly", function(value, element) { > return this.optional(element) || /^[a-z]+$/i.test(value); > > }, "Letters only please"); > > My problem is that I'm not sure where to place the above code so that I can > require only letters in one of my fields? > Hi,
you would please your code something like this: <script type="text/javascript"> jQuery.validator.addMethod("lettersonly", function(value, element) { return this.optional(element) || /^[a-z]+$/i.test(value); }, "Letters only please"); $().ready(function() { $("#submit").validate({ errorPlacement: function(error, element) { error.insertBefore(element); }, rules: { name: { required: true, lettersonly: true // assuming you want name to be validated with lettersonly }, email: { required: true, email: true } }, messages: { name: "Please enter your name", email: { required: "Please enter your email", email: "Please enter a valid email address" } } }); }); </script> Regards, Dave Buchholz I-CRE8 Internet Solutions http://www.i-cre8.co.uk Skype: I-CRE8