[英]jQuery - Validate date on datetime picker click on SharePoint
I have developed a custom Web Part on SharePoint 2013. 我在SharePoint 2013上开发了自定义Web部件。
I'm using the default date picker control. 我正在使用默认的日期选择器控件。 I also have an array with all the holidays in Italy, and I would like to "validate" the selected date just after the user clicks on the datetimepicker.
我还拥有一个包含意大利所有假期的数组,我想在用户单击datetimepicker之后“验证”所选的日期。 Validate in my case should be print an alert message if the selected date is a holiday.
如果选择的日期是假期,在我的情况下应验证是否打印警报消息。
I've tried this code, but it is not firing: 我已经试过了这段代码,但是没有触发:
$(".ms-picker-table a").on("click",function() {
console.log("ON CLICK DATEPICKER");
/* DATES CHECK */
[...]
});
ms-picker-table
is the class of the date picker control. ms-picker-table
是日期选择器控件的类。
a
elements inside this table already contain code in href
attribute: 该表内
a
元素已包含href
属性中的代码:
javascript:ClickDay('01\u002f06\u002f2017')
I don't know if it can create problems. 我不知道它是否会造成问题。
Also parent td element of each link has this code: 每个链接的父td元素也具有以下代码:
onclick="javascript:ClickDay('01\u002f06\u002f2017')"
So is there a way to correct my code to check dates when a user select a value from datepicker? 那么,当用户从日期选择器中选择一个值时,是否有一种方法可以更正我的代码以检查日期?
onBlur event should do the job onBlur事件应该做的
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="date" id="dateField"> <script> $("input[id*='dateField']").blur(function(){ var dateValue=$("input[id='dateField']").val(); console.log(dateValue); // check array to see if the date is in the Array }); </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.