Using the validation plugin
(http://bassistance.de/jquery-plugins/jquery-plugin-validation/), just
specify rules for fields, but leave out required:

jQuery.validator.addMethod("lettersonly", function(value, element) {
        return this.optional(element) || /^[a-z]+$/i.test(value);
}, "Letters only please");

$("#myform").validate({
  rules: {
    firstname: {
      lettersonly: true
    }
  }
});

Jörn

On Fri, Jan 30, 2009 at 9:08 AM, scvinodkumar
<scvinodkumar....@gmail.com> wrote:
>
> hi there,
>
> i found jquery is very useful to validate to html page.  Thanks for
> all your effort.
>
> Now i want to validate the form but they are not required. only if the
> text box or other field needs to validate onblur or onclick.
>
> For example, if there is first name field, then it should contain only
> letters. so this should be validate. and at the same time they submit
> the form without filling the first name.
>
> i searched google, but dont find the solution for this. please tell me
> how to do this.
>
>

Reply via email to