There is the group-option. See
http://docs.jquery.com/Plugins/Validation/validate for 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?
>

Reply via email to