Login Retreive lost passwordRegister
Search

Forum Index / General / add user ajax validation routine

[ This topic is solved ]

  xymod 27 May 10 / 16:22  
Hi

Is the a simple, documented way to hook my own php validation routine into the ajax routines? Or will I just have sit down and pour over the code...

Thanks

  Johan Wiegel (Admin) 27 May 10 / 16:25  
The only way to achive this is to add your validation function to the FH validator class located in includes/class.Validator.php

  xymod 03 June 10 / 16:10  
Changed at 03 June 10 / 16:10
Hi I added my methods to the Validate class, but I am getting the error

Fatal error: Call to a member function getValue() on a non-object in class.Validator.php on line 456

The problem is my function needs to get a another Datefields value to compare for validation:

Class Validate 
                {
                    Other methods etc...                    
                    function validateDate($stop_date)
                    {
                     global $form;
                     $stop_date  = strtotime($this->ukDatetoUSDate($stop_date)); //ukDatetoUSDate is another function (method) I added to the Validate class
                     $start_date = strtotime($this->ukDatetoUSDate($form->getValue("startDate")));// $form is the formHandler instance 
                     if($stop_date < $start_date) 
                      {
                      // invalid
                      return false;
                      } 
                      else 
                      {
                      // valid
                      return true;
                      } 
                    }
                }
                


The startDate value is returned (it can be echo'd) but the error is triggered which stops the validation method working.
Any ideas?

Thanks.

  Johan Wiegel (Admin) 03 June 10 / 16:18  
The validator class used in the ajax validator does not know anything about the form object.

What you want is not possible!

  xymod 03 June 10 / 18:16  
Hi

I have modified the class.AjaxValidator.php to work with the class.Validator.php class.

It seems really odd that inside my method in the Validate class, if I add:

 global $form;
 $startdateArray =  $form->_fields["startDate"][1]->getAsArray();;

 $start_date = $startdateArray[1]."/".$startdateArray[2]."/".$startdateArray[0];
 echo $start_date;

This Echoes out the date perfectly, but I still get an error :(
I will play around with it some more...

  Johan Wiegel (Admin) 03 June 10 / 18:39  
Changed at 04 June 10 / 10:47
it's not posible.

the ajax validation is posted to the server and does not know anything about your session,or the globals you use in your globals

  xymod 04 June 10 / 10:46  
Doh! Sorry, I must of had my 'stupid hat' on yesterday!
Thanks for putting me straight - I couldn't see the forest for the trees :)

  akki singh 19 June 10 / 17:56  
Changed at 19 June 10 / 18:00
I am also facing this type of problem.
thanks for help......

  Top


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