先输入确认密码再输入密码字段,错误提示不正常


On entering confirm password first then password field,the error message is not displayed properly

我有2个字段-密码和确认密码如果我先在确认密码字段中输入一个值,然后再在密码字段中输入一个值,如果匹配则显示"密码匹配",如果不匹配则显示"密码不匹配"。但目前它对我不起作用。你能帮我解决这个问题吗

这里是代码- Ajax调用

$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] . ''');');

和业务调用-

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;
        }

我把注释复制到这里,以便将来参考知道做了什么:

哼…if((strlen($sPass) != 0 && strlen($sConfirm)) != 0) ? ?我将$pass更改为$sPass并添加了!= 0,我还将||更改为&&,因为两者都不需要为空才能相同。——Sebastien

这是不工作@Sebastien主要的概念是我将首先进入确认密码字段的密码字段。如果pwd匹配,应该显示"pwd匹配",如果不匹配,应该显示"pwd不匹配"。——user3630920

你能帮我吗,如果要求是-如果确认pwd字段包含一些值,如果我试图在pwd字段中输入一些值,那么确认pwd字段应该被清空。——user3630920

你必须在$('#passwordFieldID').on('focus', function(){$('#ConfirmFieldsID').val('')}); - Sebastien

行中做一些javascript/jquery的东西