Hi - more problems I can't quite figure out... thanks for any help.
The text of my setErrorMessage is being removed by the Ajax validator js even though the is a validation error.
Rough example code below - enter a date less that 14/04/2010 and submit and and an error should be shown (turns red) but the text disappears from the containing setErrorMessage span. It is like the ajax is not using the bespoke validation function I added:
// include the class
include('/formhandler1212/class.FormHandler.php');
$form = new FormHandler();
$form->enableAjaxValidator( true );
$form -> useTable(false);
$form -> jsDateField("To", "endDate","validateUKDate",true,"d/m/y","5:15");
$form -> setErrorMessage( "endDate", "The end date!");
// submitbutton beneath it
$form->submitButton("Submit");
// set the 'commit after form' function
$form->onCorrect("doRun");
// send the form to the screen
$form->flush();
// function to show a message
function doRun($data)
{
return "Thankyou";
}
// check input date
function validateUKDate( $stop_date )
{
global $form;
$stop_date = strtotime(ukDatetoUSDate($stop_date));
$start_date = strtotime(ukDatetoUSDate("14/04/2010"));
if( $stop_date < $start_date )
{
return false;
}
else
{
return true;
}
}
// US output from UK format dd/mm/Y to timestamp
function ukDatetoUSDate ($ukDateString) {
list($d, $m, $y) = explode('/', $ukDateString);
$given ="{$y}-{$m}-{$d}";
return $given;
}
?>