views:

26

answers:

1

I am trying to figure out how to show validation error messages on my registration page. For jQuery Validation plugin examples they use a class called "require" for required fields. Is that what I have to do to include the required field validator? I guess I don't understand how this plugin works. If somebody could explain this it would be very helpful.

A: 

The documentation can be a bit abstruse, but the info is really all there.

Essentially, you add some rules to your fields. If the rules are any of the default rules (like required), there is a default message. If you want a special message or you have special rules, you can put them in the messages object. e.g.

$("form[name='my_form']").validate({
    ignore: ":hidden", //do not validate form fields in invisible sections
    rules: {
        title: {required:true, minlength:5},
        event_type_id: required,
        description: {required:true, minlength:5}
              },
    messages: { event_type_id: "Choose an event type."}
});
dnagirl
Thanks for your reply..I will try a sample code.
shanthiram