ここで、選択した日付が今日の日付よりも大きいことを検証しています。必要に応じて変更できます。
<script>
AUI().ready('aui-form-validator', 'aui-overlay-context-panel', function(A) {
A.mix(
YUI.AUI.defaults.FormValidator.RULES,
{
dateCustomRule: function(val, fieldNode, ruleValue) {
var val = new Date(Date.parse(val,"MMM dd yyyy"));
var today=new Date();
return (val>today);
}
},
true
);
var validator2 = new A.FormValidator({
boundingBox: document.<portlet:namespace/>form,
fieldContainer: 'p',
rules: {
<portlet:namespace />dueDate:{
required: true,
dateCustomRule:true
}
},
fieldStrings: {
<portlet:namespace />dueDate: {
required: 'Due Date Required',
dateCustomRule: 'Date must be greater than Today\'s Date'
}
},
on: {
validateField: function(event) {
},
validField: function(event) {
},
errorField: function(event) {
},
submitError: function(event) {
var formEvent = event.validator.formEvent;
var errors = event.validator.errors;
},
submit: function(event) {
var formEvent = event.validator.formEvent;
return false;
}
}
});
});
</script>