douduan3203 2014-12-02 09:35
浏览 73
已采纳

如何防止用户使用sugarcrm中的ajax在新密码字段中输入以前的密码?

I want to add some JavaScript validations in existing JavaScript validations when user changes his password.

Now, I want to use AJAX to connect with PHP file which runs db query against the current user and check whether the entered password in new_password field is matches with his last 10 passwords.

Now, I found out those function which SugarCRM uses to match passwords with the hashed passwords stored in database. But, the problem is I don't know how to use AJAX to connect to PHP file in SugarCRM.

I want to add JavaScript validation using onblur function. When user enter his new password, using onblur, I want to send that password value to PHP file using AJAX and return that value. And when user click save button, it should give alert box if his new password matches with his last passwords and if not it should allow him to change his password.

Can anyone here guide me soon? Any help is appreciated.

  • 写回答

2条回答 默认 最新

  • doudui9516 2015-02-10 09:24
    关注

    I have managed to find the answer as I want. I am sharing my code with you all.

    if(form.new_password.value!=''){
            $.ajax({
                url:'index.php?entryPoint=check_last_passwords',
                data:{new_password: $('#new_password').val(),
                record: $('#record').val()},
                success: function(data){
                    if(data!=''){
                        alert("Error: New password should not match with the last 10 passwords.");
                        return false;
                    }else{
                        var _form = $('#EditView')[0];
                        if (!Admin_check())
                            return false;
                        _form.action.value='Save';
                        set_chooser();
                        if(verify_data(EditView))
                            _form.submit();
                    }
                }
            });
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?