Fórumok
<aui:validator> for dates?
Richard Oliver Legendi, módosítva 10 év-val korábban
<aui:validator> for dates?
Junior Member Bejegyzések: 35 Csatlakozás dátuma: 2009.11.30. Legújabb bejegyzések
I'm trying to make a simple custom aui:validator for the birthday field on the registration form but it is simply not working. Any ideas?
What I'd like to achieve is to check if the user is 18 years old at the registration.
Any hints would be greatly appreciated!
<aui:input name="birthday" value="<%=birthday%>">
<aui:validator name="custom" errormessage="some-error">
function (val, fieldNode, ruleValue) {
return false;
}
</aui:validator>
</aui:input>
What I'd like to achieve is to check if the user is 18 years old at the registration.
Any hints would be greatly appreciated!
Antoine Comble, módosítva 10 év-val korábban
RE: <aui:validator> for dates?
Regular Member Bejegyzések: 232 Csatlakozás dátuma: 2012.09.07. Legújabb bejegyzések
Hi,
I've a post could interest you : http://stackoverflow.com/questions/16836724/liferay-auivalidator-for-dates
Hope this help you,
Antoine
I've a post could interest you : http://stackoverflow.com/questions/16836724/liferay-auivalidator-for-dates
Hope this help you,
Antoine
Richard Oliver Legendi, módosítva 10 év-val korábban
RE: <aui:validator> for dates?
Junior Member Bejegyzések: 35 Csatlakozás dátuma: 2009.11.30. Legújabb bejegyzések
Hi Antoine,
Yeah, I was the same person asking the same thing ther too :-))
Best,
Richard
Yeah, I was the same person asking the same thing ther too :-))
Best,
Richard
Antoine Comble, módosítva 10 év-val korábban
RE: <aui:validator> for dates?
Regular Member Bejegyzések: 232 Csatlakozás dátuma: 2012.09.07. Legújabb bejegyzések
Hi Richard,
Sorry...
Regards,
Antoine
Sorry...
<aui:input name="birthday" value="<%=birthday%>">
<aui:validator name="custom" errormessage="some-error">
function (val, fieldNode, ruleValue) {
var date = new Date(val);
if (isDate(date) && (date != INVALID_DATE) && !isNaN(date)) {
// it's a valid date
var today = new Date();
var yyyy = today.getFullYear();
return (date.getFullYear() + 18) < yyyy;
}
}
</aui:validator>
</aui:input>
Regards,
Antoine
Richard Oliver Legendi, módosítva 10 év-val korábban
RE: <aui:validator> for dates?
Junior Member Bejegyzések: 35 Csatlakozás dátuma: 2009.11.30. Legújabb bejegyzések
Hi Antoine,
Hehe, sorry, I wasn't clear enough (and there are a few things I figured out so far :-) I did not had any issues with implementing the JavaScript part . My issue was that I thought there is a trivial error with my usage, but it turned out when I try to use this on the create_account.jsp page (I had to hook it for a Liferay issue which has been fixed in the master branch but wasn't available yet in 6.1.1), it is simply not working (haven't tracked it down yet why, though).
My solution was simply verifying the date from Java and throwing an exception handled something like <liferay-ui:error exception="<%=NotOldEnoughException.class%>" message="Not old enough" /> on the JSP side. I wasn't able to use the JavaScript validator.
Anyway, thanks for your time :-)
Hehe, sorry, I wasn't clear enough (and there are a few things I figured out so far :-) I did not had any issues with implementing the JavaScript part . My issue was that I thought there is a trivial error with my usage, but it turned out when I try to use this on the create_account.jsp page (I had to hook it for a Liferay issue which has been fixed in the master branch but wasn't available yet in 6.1.1), it is simply not working (haven't tracked it down yet why, though).
My solution was simply verifying the date from Java and throwing an exception handled something like <liferay-ui:error exception="<%=NotOldEnoughException.class%>" message="Not old enough" /> on the JSP side. I wasn't able to use the JavaScript validator.
Anyway, thanks for your time :-)