Validate a calendar field with a custom javascript code

hilmata 02 Feb, 2018
Hello. I'm trying to perform a verification for my calendar field but my javascript code don't work. I want my field to display an error message when the user put a date greater than today's one.

jQuery.fn.form.settings.rules.verifdatecreation = function(value, param) {

var currentDate = new Date().setHours(0,0,0,0);
var selectedDate = new Date(value);

if (selectedDate > currentDate) {
return false;
}else{
return true;
}
};
Max_admin 10 Feb, 2018
Answer
Hi tchaabid,

You do not need to validate this, open the calendar advanced settings and set the "End date" to:
{date:Y-m-d}
This will restrict the date selection to end on the same day.

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.