I am new to jQuery and to the validate plugin. In fact, my initial use of jQuery is to try to use the validate plugin. So, please, bear with my possibly stupid questions.
I have worked with all the demos and have them working fine in my environment. I have lifted and stripped down the demo.html validation and tried to use it in my application which is, essentially, an catalog/order form wherein each "line item" contains a form with a qty input and "buy it" submit button. If I give a couple forms (for a couple specific line items) IDs, the following works fine. ---------------------------------------- <script type="text/javascript"> $().ready(function() { // validate form with id BUYIT1 using class attribute validation values $("#BUYIT1").validate({ // debug: true }); // validate form with id BUYIT2 using based on rules entered here $("#BUYIT2").validate( { // debug: true, rules: { itemquant: { required: true, digits: true, minLength: 2 } }, messages: { itemquant: { required: "Please enter a qty", digits: "Qty must be a number", minLength: "Qty must be at least 2 digits" } } }); }); </script> <style type="text/css"> #BUYIT1 label.error { margin-left: 10px; width: auto; display: inline; color: red; } #BUYIT2 label.error { margin-left: 103px; width: auto; display: inline; color: red; } </style> ---------------------------------------- However, it I try to validate ALL the line item forms using validate based on the form class, it does not work. ---------------------------------------- <script type="text/javascript"> // $.validator.setDefaults({ // submitHandler: function() // { // // alert("submitted!"); // } // }); $().ready(function() { // I also tried these // $("form:has(input[id='itemquant'])").validate( // $("form:has(input[name='itemquant'])").validate( //$("form.BUYITBELOW:has(*[name='itemquant']:visible").validate( // $("input[name='itemquant']").validate( // validate form with class BUYITBELOW based on rules entered here $("form.BUYITBELOW").validate( { debug: true, rules: { itemquant: { required: true, digits: true, minLength: 2 } }, messages: { itemquant: { required: "Please enter a qty", digits: "Qty must be a number", minLength: "Qty must be at least 2 digits" } } }); }); </script> form.BUYITBELOW label.error { margin-left: 103px; width: auto; display: inline; color: red; } </style> ---------------------------------------- All of the above selectors seem to work when tested in firebug; that is, the proper line items (forms) are found. 1) Is it possible to validate one or more forms in a given page based on something other than id? 2) If yes, what (probably simple thing) am I missing in the above? 3) If no, is it possible using a different approach such as adding a button (instead of a form), detecting when any button of a given class/type is clicked, and programatically performing the validation and the submission? Thanks R.Parr, RHCE, Temporal Arts Portland, OR, U.S.A.