views:

46

answers:

1

I am looking at validation of some text boxes for things like required, minlength, max length, email etc... I am able to get examples that work fine on submit button on page. I want to do this validation on a button click which will only raise a Ajax request and not submit of page.

On the Internet all the samples found was with a submit button. Is there an easy way to change this code a little bit to make it work for non submit button click or any new jQuery or Java plugin to do the same?

I am using the jquery.validation.js for now. This works with submit buttons.

Any kind of help with suggestion or help is appreciated.

+1  A: 

The jQuery validator plugin already handles this. Just tweak some of the options in the validate method.

As quoted in the documentation for the onfocusout option:

Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid.

Code Example:

$("#form").validate({
  onfocusout: false
});

That's just one of a few dozen options you can configure. You can see the full list of options for the validate method here: http://docs.jquery.com/Plugins/Validation/validate#options

Damien Wilson