I am using Gravity Forms with the date picker, and I need to show an alert if someone clicks a weekend. Here is my code:
$( document ).ready(function() {
$("#input_2_3").datepicker({ // ID of the date picker field
onClick: function (selectedDate) {
var date = $(this).datepicker('getDate');
var day = date.getDay();
if (day === 6 || day === 7) {
alert('you clicked a weekend!');
}
}
});
});
The problem is that absolutely nothing happens, and no complaints from the console either.
What’s going on? If it helps to know, my date format is dd-mm-yy
2
Answers
The solution was to place the script BEFORE the form. Problem solved.
You must use "onSelect" event. Look this fiddle.
http://jsfiddle.net/0zdn8fh4/
Edit, try adding one onchange, it should works: