Bonjour,
SVP dites moi pourquoi beforeshow déclanche onchangemonthyear dans mon code si dessous sachant que j'ai 2 champs date et que la date affichée par défaut dans les 2 chmps est (MoisEnCours - 1):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
jQuery(document).ready(function() {
	var currentTime = new Date();
	jQuery('.date-picker').datepicker({ // .date-picker : la classe de mes 2 champs date
		dateFormat: 'mm/yy',
		showOn: "both",
		minDate: new Date(currentTime.getFullYear(), "01", "00"), // année en cours
		maxDate: new Date(currentTime.getFullYear() + 3, "11", "30"), // année courante + 3
		beforeShow: function(input, inst) { // pour remplir le datepicker par la valeur du champ text
			if ((datestr = jQuery(this).val()).length > 0) {
				year = datestr.substring(datestr.length - 4, datestr.length);
				month = datestr.substring(0, datestr.length - 5);
				jQuery(this).datepicker('option', 'defaultDate', new Date(year, month - 1, 1));
				jQuery(this).datepicker('setDate', new Date(year, month - 1, 1));
			}
		},
		onChangeMonthYear: function(year, month, inst) { // pour remplir la valeur du champ par celle du datepicker
			if (_isDate("01/" + jQuery(this).val())) { // test validité de date
				inst.input.datepicker('setDate', new Date(year, month - 1, 1));
				statsDateChange(true); // appel d'une fonction de controle (afficher un message si date1 > date2)
			}
		}
	});
});