Primefaces 防止00:00的黄金时段选择器
我正在使用primefaces选择器,我被要求阻止用户从选择器中选择00:00,请我想知道这是否可行您可以使用日历的Primefaces 防止00:00的黄金时段选择器,primefaces,datepicker,Primefaces,Datepicker,我正在使用primefaces选择器,我被要求阻止用户从选择器中选择00:00,请我想知道这是否可行您可以使用日历的onselect和onkeyup调用js验证功能 比如说 <p:calendar widgetVar="myValidDateWidget" onselect="myValidatorFunc();" onkeyup="myValidatorFunc();"/> 阅读关于js日期对象的更多信息:我知道这些属性,这将导致我无法写入00:01或8:00。我正在使用
onselect
和onkeyup
调用js验证功能
比如说
<p:calendar widgetVar="myValidDateWidget" onselect="myValidatorFunc();"
onkeyup="myValidatorFunc();"/>
阅读关于js日期对象的更多信息:我知道这些属性,这将导致我无法写入00:01或8:00。我正在使用timeOnly=“true”的prime faces日历控件。。因此,该字段首先没有焦点。如果我正确理解了您的要求,可以使用日历组件的minHour、maxHour、minminminute和maxMinute属性来实现该字段。再次说明:如果我设置minminminminute=“01”,我将无法写入8:00
function myValidatorFunc(){
var enteredDate = myValidDateWidget.getDate();
var newDate = enteredDate();
var minutes = enteredDate.getMinutes();
var hours= enteredDate.getHours();
//do your checks here...
//in case of validation error modify the entered date and
// set the date of your calendar like this myValidDate.setDate(newDate);
}