0

I'm trying to validate a registration form with jQuery Validate plugin. One of the requirements is that the select field must select a persons minimum age (13).

How would i do that? I can figure out the minimum year but i can't figure out how jquery validate picks a range described here: http://docs.jquery.com/Plugins/Validation/Methods/min#value

Form markup:

<form>
...
<select id="yearborn" name="yearborn">
<option value="" disabled="disabled">Choose an option</option>
<option value="1901" >1901</option>
<option value="1902" >1902</option>
<option value="1903" >1903</option>
...
<option value="2011" >2011</option>
</select>
</form>

Then the attempted jQuery form validation:

jQuery('#register-form')
      .validate({        
        submitHandler: function(form) {
        form.submit();      
        },
        rules: {
          yearborn: {
            required: true,
            min: 13
          }
        }
    });

Any ideas? I looked over this thread but it's related to requiring input:

Community
  • 1
  • 1
chrisjlee
  • 21,691
  • 27
  • 82
  • 112

1 Answers1

0

Why even give the user the option to choose an invalid year ?

If you can control the server-side that prints the select-box, just print the allowed years (this year - 13),

otherwise min should be a year, not an age ...

min 1998 == 2011-13 (this year - 13)

anderssonola
  • 2,195
  • 16
  • 29
  • If i did it that way everyone that signs up by default can become a member. Rendering it pointless. – chrisjlee Aug 02 '11 at 00:16
  • if values in – anderssonola Aug 02 '11 at 06:29