Thank you Jörn for the reply. a bit modified code to show what exactly needed... Here I have added a new 2 textboxes and a button now the requirement ( as ASP.NET does) is when "Submit Name" button is pressed then only the group "username" should be validated and if both the textboxes of the group "username" are filled (AND the address textboxes are EMPTY) the form should be submitted. In normal HTML this can be done using the different forms but in ASP.NET there is only one FORM that is runat server that encapsulates other server controls.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/ plugins/validate/jquery.validate.js"></script> <script> $(document).ready(function(){ $("#myform").validate({ groups: { username: "fname lname", address: "address1 phone" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) error.insertAfter("#lastname"); else error.insertAfter(element); }, debug:true }) }); </script> </head> <body> <form id="myform"> <label>Your Name</label> <input name="fname" class="required" value="Pete" /> <input name="lname" id="lastname" class="required" /> <input name="address1" class="required" /> <input name="phone" id="lastname" class="required" /> <br/> <input type="submit" value="Submit Name"/> <input type="submit" value="Submit Address"/> </form> </body> </html> On Feb 17, 6:48 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com> wrote: > There is the group-option. > Seehttp://docs.jquery.com/Plugins/Validation/validatefor details. > > Specify grouping of error messages. A group consists of an arbitrary > group name as the key and a space separated list of element names as > the value. Use errorPlacement to control where the group message is > placed. > > Use a table layout for the form, placing error messags in the next > cell after the input. > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <script src="http://code.jquery.com/jquery-latest.js"></script> > <script type="text/javascript" > src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script> > <script> > $(document).ready(function(){ > $("#myform").validate({ > groups: { > username: "fname lname" > }, > errorPlacement: function(error, element) { > if (element.attr("name") == "fname" > || element.attr("name") == "lname" ) > error.insertAfter("#lastname"); > else > error.insertAfter(element); > }, > debug:true > }) > }); > </script> > > </head> > <body> > <form id="myform"> > <label>Your Name</label> > <input name="fname" class="required" value="Pete" /> > <input name="lname" id="lastname" class="required" /> > <br/> > <input type="submit" value="Submit"/> > </form> > </body> > </html> > > Jörn > > On Tue, Feb 17, 2009 at 11:09 AM, Paresh <paresh.m.jaga...@gmail.com> wrote: > > > Greetings, > > is there anyway to have the "validationGroup" kind of functionality > > that is in the ASP.NET validation? because there are no multiple forms > > and validation on set of controls required based on the similar > > grouping? Like a set of controls share a similar group and then on > > click of a button the validationGroup is set into the jQuery validator > > options and then in the validation only those controls are validated > > which have that specific validationGroup > > > like > > rules: { > > TextBox1: 'required', > > TextBox2: 'required' > > TextBox3: 'required', > > TextBox4: 'required' > > > }, > > messages: { > > TextBox1: 'Please enter the name.', > > TextBox2: 'Please enter last name.' > > TextBox3: 'Please enter address.', > > TextBox4: 'Please enter phone number.' > > > }, > > > validationGroups: { > > group1:{TextBox1,TextBox2} > > group2:{TextBox3,TextBox4} > > } > > > <input type submit onclick=validator.validationGroup='group1' > > text='Fill Primary information'> > > <input type submit onclick=validator.validationGroup='group2' > > text='Fill contact information'> > > > or something similar?