Login Retreive lost passwordRegister
Search

Forum Index / General / Ajax validation bug?

[ This topic is solved ]

  xymod 14 April 10 / 22:16  
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:

<style type="text/css">
 .error {color:red;}
</style>

<?php

// include the class
include('/formhandler1212/class.FormHandler.php');
 
$form = new FormHandler();
$form->enableAjaxValidatortrue );
$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;   
}
?>

  Johan Wiegel (Admin) 14 April 10 / 22:33  
Hmm, datefields should not be validated bij Ajax validation, some code disapeard there. Fixed in the new download.

  xymod 14 April 10 / 23:20  
Cool - fixed. Thanks again :)

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license