I have 2 fields - Password and Confirm Password If I enter a value in confirm password field first and then enter value into password field, message saying "password matched" if matching and "password does'nt match" if mismatching should be displayed. But presently it is not working for me. Could you please help me in fixing this issue
Here is the code - Ajax Call
$aVal = $this->get('val');
Phpfox::getService('confirmpassword')->password($aVal['password'], $aVal['password_confirm']);
if (Phpfox_Error::isPassed()) {
$this->call('$(\'#js_password_match\').css(\'background-color\', \'#00AA00\');');
$this->call('$(\'#js_password_match\').css(\'padding\', \'1.05px\');');
// $this->call('$(\'#js_password_match\').css(\'margin-left\', \'5px\');');
$this->call('$(\'#js_password_match\').html(\'' . Phpfox::getPhrase('confirmpassword.password_matched') . '\');');
return true;
}
$aErrors = Phpfox_Error::get();
$this->call('$(\'#js_password_match\').css(\'background-color\', \'#DD0000\');');
$this->call('$(\'#js_password_match\').css(\'padding\', \'1.05px\');');
//$this->call('$(\'#js_password_match\').css(\'margin-left\', \'5px\');');
$this->call('$(\'#js_password_match\').html(\'' . $aErrors[0] . '\');');
and Service call -
public function password($sPass, $sConfirm)
{
if((strlen($pass) || strlen($sConfirm)) != 0)
{
if(strcmp($sPass, $sConfirm) != 0)
{
Phpfox_Error::set(Phpfox::getPhrase('confirmpassword.password_does_not_match'));
}
}
else
{
Phpfox_Error::set(Phpfox::getPhrase('confirmpassword.empty_password_field'));
}
return $this;
}