Hello,
in the kalendar validation you should have following:
function ff_Kalender_validation(element, message)
{
if ([size=5][i]your condition[/i][/size]) {
if (message=='') message = element.name+" faild in my test.\n"
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_Kalender_validation
Instead of your condition, you input your javascript condition that will check if entered value is less than 3 days away from now. Now when the value is okay, it will submit, if it is not okay then it will show message.
And for php file and AJAX for checking is there catering booked on that day, it should be something like this:
catering.php file created in root folder, with content:
<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/' ));
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
$date= $_GET['date'];
$database = &JFactory::getDBO();
$sql = "SELECT count(*) FROM jos_facileforms_subrecords WHERE date = $date";
$database->setQuery( $sql );
$result=$database->loadResult();
header('Content-type: application/json');
header('Access-Control-Allow-Origin: *'); // CORS Settings
echo $result;
?>
And AJAX code should be in initialization script, that on change of the calendar value, user gets alerted that date already has catering reserved, it should look something like this:
var url = document.location.origin + '/catering.php';
jQuery("#ff_elem7").change(function(){
jQuery.ajax({
type: 'GET',
url: url1,
data: 'date=' + jQuery("#ff_elem7").val(),
success: function(data){
//Code that should execute when you get if there is catering on that day or no
example: if(data!=0){
alert('There is already...');
}
}
});
});
I hope you can implement this. If not I will assist you.
Best regards,
Marinko