Using minDate and maxDate option with datepicker on Form.

Permalink
Hi All,

I'm trying to add a datepicker that restricts the valid dates to be entered for a user's DOB. Here's my js to add the functionality.

$().ready(function(){
  $('.ccm-input-date').datepicker({
    changeYear: true,
    showAnim: 'fadeIn',
    minDate: "-22Y",
    maxDate: "-15Y",
    dateFormat: "dd M yy",
    changeMonth: true
  }).val('');
});


However, when I use the form/helper to build the form the date restrictions don't work. I think it has something to do with the js added by the helper when constructing the datepicker form field, but I'm not sure.

Anyone else come up against this problem, and do you have a solution.

Cheers,
Gordon

View Replies:
gogza replied on at Permalink Reply
OK I managed to do what I wanted!

By overriding the date-time form helper at:

concrete/helper/form/date-time.php


Overriding helpers is a little more complicated than other c5 objects, see http://www.concrete5.org/community/forums/customizing_c5/include-pa... for a great explanation.

I removed the js embedded in the html for the date-time attribute - meaning I could add my own jquery datepickers instead of the default one. Ta da!

HTH someone,
Gordon