Setting the minimum and maximum year can be accomplished by adding the following code to your functions.php file:
add_filter("gform_date_max_year", "set_max_year");
function set_max_year($max_year){
return 2016;
}
add_filter("gform_date_min_year", "set_min_year");
function set_min_year($min_year){
return 2013;
}
Now limiting the hour and minute will require adding a little jQuery to you form's page template. Using the following code will cause any hour less than 1 to change to 1 and any number greater than 12 to turn into 12. Same goes for the minute. Any number less than 0 will turn to 0 and any number greater than 59 will turn to 59.
<script type='text/javascript'>
jQuery(document).ready(function( $ ) {
$('#input_3_2_1').change(function() {
if ($(this).val() < 1){ $(this).val(1);}
if ($(this).val() > 12){ $(this).val(12);}
});
$('#input_3_2_2').change(function() {
if ($(this).val() < 0){ $(this).val(0);}
if ($(this).val() > 59){ $(this).val(59);}
});
});
</script>
You will just need to change 'input_3_2_1' to the ID of your hour form select and 'input_3_2_2' to the ID of your minute form select. You locate their IDs by viewing the page source of your form.
I hope this answers your questions.
Posted 11 years ago on Thursday May 2, 2013 |
Permalink