// set event handler which checks the date for "high" values $(document).ready(function () { $("form").submit(function (e) { flagProceedWithSubmit = true; if ($("#tableRow").length == 0) return true; alert("this: " + $(this).value); $(".appDatePickClass").each(function (index, item) { if ((new Date(item.value) - (new Date()) > 2*30*24*3600*1000)) { flagProceedWithSubmit = false; } }); if (!flagProceedWithSubmit) flagProceedWithSubmit = WarnDate(); return (flagProceedWithSubmit); }); // function not transposed to view Edit });
When I submit the form with a date too high, a dialog appears, but when I press the button "Sim" ("Yes"), the form get submitted through the submit with date check, and not through the submit before the handler that I defined.
The problem is that when I try to pick a date with the datepicker, for the second <input> the datepicker assignes the date selected to the first <input> !!!!!!
How can I have the right behavior with datepicker?
Thank you.
P.S. - I also tried:
var n = $("#tableRow #p_Data").length; for (var i = 0; i < n; i++) { $("#tableRow #p_Data[data-key='" + i + "']").datepicker({ dateFormat: "yy-mm-dd" }); }