You should be able to do that using JavaScript (so on client side). If you look on the Client API doc, you can see that there is a getCurrentDate()
JavaScript function provided by the rich:calendar component.
So what you have to do is to launch a JavaScript function on the JavaScript events ondateselected
and oninputchange
that will use the getCurrentDate()
method and compare to the current date.
Something like that (I didn't test):
<h:form id="myForm">
...
<rich:calendar id="myCalendar" enableManualInput="true" value="#{home.born}" datePattern="dd/MM/yyyy"
ondateselected="checkDate();" oninputchange="checkDate();"/>
...
and
<script type="text/javascript">
function checkDate() {
var choosenDate = $("myForm:myCalendar").component.getCurrentDate();
var now = new Date();
// Calculate the difference between the 2 dates.
// This method may be modified if you want to only compare date (i.e. not time).
var diff = choosenDate.getTime() - now.getTime();
if (diff < 0) {
// choosenDate is before today
alert("Error in the selected date!");
// Do what you want here...
}
}
</script>