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条)

报告相同问题?

悬赏问题

  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答