Skip to content

Instantly share code, notes, and snippets.

@ksnider
Last active August 29, 2015 14:13
Show Gist options
  • Save ksnider/033fe19c26c60a722871 to your computer and use it in GitHub Desktop.
Save ksnider/033fe19c26c60a722871 to your computer and use it in GitHub Desktop.
This script will allow you to pop up a calendar on a date field in an Infusionsoft web form for easy entry of dates
/*
Instructions: This script will allow you to pop up a calendar on a date field for easy entry of dates. It needs to be
modified in order to work. In the code below, replace the REPLACE WITH INFUSIONSOFT FIELD NAME with a # and the ID
of the field(s) you want to add the date picker for. Make sure you leave the single quotes in place.
Common date field names:
Birthday - #inf_field_Birthday
Anniversary - #inf_field_Anniversary
Custom date fields will be in the format of: inf_custom_CustomFieldName (instead of CustomFieldName it is the name of
the field in the database)
Advanced: You can make changes to the settings of the date picker by putting values in between
the parenthesis of the datepicker() part of the code. You can also set a number of options at one time.
For example:
datepicker({ changeYear: true }); Allows the user to choose the year from a dropdown box
datepicker({ defaultDate: +7 }); Sets the default date to 7 days in the future
datepicker({ defaultDate: -7y }); Sets the default date to 7 years in the past
datepicker({ defaultDate: +3m }); Sets the default date to 3 months in the future
datepicker({ defaultDate: -5w }); Sets the default date to 5 weeks in the past
datepicker({ defaultDate: -7y -2m -1w -5d }); Sets the default date to 7 years 2 months 1 week and 5 days in the past
datepicker({ defaultDate: -5w; changeYear: true; }); Sets the default date to 5 weeks in the past and adds the year dropdown
For a full list of options see: http://jqueryui.com/demos/datepicker/
Modify the code below then copy and paste it into an HTML area on your webform.
*/
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript">
if (typeof jQuery === 'undefined') {
document.write('<script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>');
} $ = jQuery;
$(document).ready(function() {
var dateFields = [
'REPLACE WITH INFUSIONSOFT FIELD NAME' // If you need more datepickers, add field names separated by comma
];
$.each(dateFields, function (idx, val) {
if ( ! $('#' + val).length) {
return;
}
$('#' + val).datepicker({ changeYear: true }); // remove { changeYear: true } if year should be fixed
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment