jQuery Validate Plugin

jQuery Validate Plugin

Hi there,

In my form named EditWeight a user can click on a button and add one or more textboxes. I want to validate these one or more textboxes to make sure they contain either integer or decimal number.  I added this code and i have two problems.
  • * reg expression that I'm using looks correct but the code always says does not validate
  • * I don't know how to display the error message to use when the textboxes doesn't validate given that I have one or more textboxes.
  1.             $('#EditWeight').on('submit', function () {

                    // adding rules for inputs with names ending with Weight
                    $("input[name$='Weight']").each(function () {
                        $(this).rules("add",
                            {
                                regex: "^[1-9]\d{0,9}(\.\d{1,3})?%?$",
                                messages: {
                                    regex: "<br />Please enter valid Integer or Decimal number."
                                }
                            });
                    });

                    if ($('#EditWeight').validate()) {
                        console.log("validates");
                    } else {
                        console.log("does not validate");
                    }

                });
Joe