Skip to content Skip to sidebar Skip to footer

Datepicker Validation 18 Years Of Age

I am using a date picker from twitter bootstrap and I want to add some validation that your sign up will not suppose to be registered once your date is below 18 years of age, how a

Solution 1:

If you look down the demo page a bit, you'll see a "Restricting Datepicker" section. Use the dropdown to specify the "Year dropdown shows last 20 years" demo , and hit view source:

$("#restricting").datepicker({ 
    yearRange: "-20:+0", // this is the option you're looking forshowOn: "both", 
    buttonImage: "templates/images/calendar.gif", 
    buttonImageOnly: true 
});

You'll want to do the same (obviously changing -20 to -100 or something).

Or you can use

$('#dp1').datepicker({
    format: 'mm-dd-yyyy',
    startDate: '-15d',
    endDate: '+0d'// there's no convenient "right now" notation yet
});

Solution 2:

You need to validate the user input either using javascript or the scripting language you're going to use.

An example in PHP would be:

<?phpif(isset($_POST['birth_date']))
{
   if($_POST['birth_date'] < 1996)
   {
      echo'You can not register';
   }

}

Post a Comment for "Datepicker Validation 18 Years Of Age"