Login Retreive lost passwordRegister
Search

Forum Index / General / checkPassword for textFields

[ This topic is unsolved! ]

  Simon Born 08 February 08 / 20:09  
i want to check the input of a new username, without having to make the input fields password fields. when using the checkPassword function on the two textFields i get this error message:

Notice: class.FormHandler.php at 2632 Error: unknown field used in checkPassword!

too bad!

i also need the validation of FH_VARIABLE and i want to check if the 2 values entered are the same. how can i combine these two functions?

simon

  Johan Wiegel (Admin) 08 February 08 / 20:18  
can you post your code?

  Simon Born 08 February 08 / 22:08  
$form->borderStart("gebruikersnaam wijzigen");
$form->TextField("huidig gebruikersnaam", "oude_gebruikersnaam", "validate_old_username", 20,64);
$form->passField("nieuwe gebruikersnaam", "nieuwe_gebruikersnaam_1", _FH_VARIABLE, 20,64);
$form->passField("herhaal nieuwe gebruikersnaam", "nieuwe_gebruikersnaam_2", _FH_VARIABLE, 20,64);
$form->checkPassword("nieuwe_gebruikersnaam_1", "nieuwe_gebruikersnaam_2", "");
$form->borderStop();

$form->submitButton("opslaan");

$form->onCorrect("mySaveHandler");

$form->flush();

so, i need fh to check the "nieuwe_gebruikersnaam" fields on being _FH_VARIABLE and also to check them being the same input. this works by making the fields passFields, but i would like to have them visible instead. it's not like it's a huge issue. however, it would be nice if it could be done.

greets
simon

  Johan Wiegel (Admin) 09 February 08 / 09:19  
I that case you have to write your own validation function.

  Simon Born 09 February 08 / 09:52  
Changed at 09 February 08 / 09:52
i was thinking that. can you tell me w things:

how can i check the 2 values of the fields in the validator (just: how can i access their values inside the validation function?) and

can i in some way use hte _FH_VARIABLE constant?

thanks for any help.

greets
simon born

  Johan Wiegel (Admin) 09 February 08 / 11:37  
http://www.formhandler.net/manual/95/Validating_Fields.html

  Simon Born 09 February 08 / 12:00  
yes, i know, but can i in any way make use of the _FH_VARIABLE constant INSIDE my own validation function i.e. something like gettype($var)==_FH_VARIABLE ?

  Teye Heimans (Founder) 09 February 08 / 12:47  
You can just make the $form object global and then get the value of an field. E.g.:

<?php

function myValidator$field1 )
{
    global 
$form;

    
$field2 $form -> getValue'field2' );

    
// validation here
}

?>


Hope it helps...

  Johan Wiegel (Admin) 12 February 08 / 21:01  
Changed at 12 February 08 / 21:01
 Quote: Simon Born
 
i was thinking that. can you tell me w things:

how can i check the 2 values of the fields in the validator (just: how can i access their values inside the validation function?) and

can i in some way use hte _FH_VARIABLE constant?

thanks for any help.

greets
simon born


Simon,

I just did some testing. This might solf your problem:

<?php
function validate_old_username$value )
{
    return 
true;    
}

function 
MyValidator( )
{
    global 
$form;
    if( 
$form->Value"nieuwe_gebruikersnaam_1" ) == $form->Value"nieuwe_gebruikersnaam_2" ) )
    {
        
// ze zijn gelijk, zijn ze ook variable?
        
$oValidator = new Validator();
        if( 
$oValidator->_IsVariabele$form->Value"nieuwe_gebruikersnaam_1" ) ) == false )
        {
            return 
"Niet variable";
        }
        else 
        {
            return 
true;
        }
    }
    else
    {
        return 
"Ze zijn niet gelijk";
        
    }
    
}

$form = new FormHandler();
$form->borderStart("gebruikersnaam wijzigen");

$form->TextField("huidig gebruikersnaam""oude_gebruikersnaam""validate_old_username"20,64);

$form->TextField("nieuwe gebruikersnaam""nieuwe_gebruikersnaam_1""MyValidator"20,64);
$form->TextField("herhaal nieuwe gebruikersnaam""nieuwe_gebruikersnaam_2""MyValidator"20,64);

$form->borderStop();

$form->submitButton("opslaan");

$form->onCorrect("mySaveHandler");

$form->flush(); 
$form->SubmitButton();
?>


Johan

  Simon Born 14 February 08 / 19:10  
Hoi Johan, bedankt voor je antwoord. Weet nog niet of het werkt omdat ik op dit moment met anderen dingen bezig zijn moet.

groet
simon

  Top


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