Skip to content

Instantly share code, notes, and snippets.

@bpmore
Last active August 6, 2019 04:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpmore/4024169cfb974d8c62ffe687f6d94d39 to your computer and use it in GitHub Desktop.
Save bpmore/4024169cfb974d8c62ffe687f6d94d39 to your computer and use it in GitHub Desktop.
gravity forms calendar picker
Make the date picker start 2 weeks from current date.
Find this in your form:
<input name="input_26" id="input_2_26" type="text" value="" class="datepicker medium mdy datepicker_with_icon hasDatepicker">
The id above equals the formID and fieldID below.
<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 2 && fieldId == 26 ) {
optionsObj.minDate = '+2 W';
optionsObj.maxDate = '+2 Y';
}
return optionsObj;
} );
</script>
For 2 calendars and GF conditionals.
<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 23 && fieldId == 64 ) {
optionsObj.minDate = '+8 W';
optionsObj.maxDate = '+2 Y';
} else if ( formId == 23 && fieldId == 66 ) {
optionsObj.minDate = '+2 W';
optionsObj.maxDate = '+2 Y';
}
return optionsObj;
} );
</script>
Add an HTML field to your form and paste the above script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment