简体   繁体   English

我的代码(用Javascript)有什么问题?

[英]What is wrong with my code (in Javascript)?

I'am really frustrated with the result I'm getting in my code: 我对代码得到的结果感到非常沮丧:

userOldPass //from user input, user's old password userOldPass //通过用户输入,用户的旧密码

oldPass //from database, user's old password oldPass //来自数据库,用户的旧密码

newPass //from user input, user's new password newPass //根据用户输入的用户新密码

confirmNewPass //from user input, user's new password confirmation ConfirmNewPass //通过用户输入,确认用户的新密码

function checkpass(){

        if(userOldPass==oldPass) && (newPass==comfirmNewPass){
            alert('success');

        }else{
            alert('error');

        }

}

The problem is it always says 'error' even if the inputs are already all correct. 问题在于,即使输入已经全部正确,它也总是说“错误”。 I checked each variables' values via the alert function to see if there is some inequalities but everything is okay and still it alerts 'error'. 我通过警报功能检查了每个变量的值,以查看是否存在一些不等式,但一切正常,并且仍会发出“错误”警报。

What could be the problem? 可能是什么问题呢?

PS all the variables are in SHA1 hash. PS所有变量都在SHA1哈希中。 I used the CryptoJS.SHA1 function I found in the net. 我使用了在网上找到的CryptoJS.SHA1函数。 I use the alert function to check each value from the variables and the results are right. 我使用警报功能检查变量中的每个值,结果正确。

 if(userOldPass==oldPass) && (newPass==comfirmNewPass) // all should stay in ()

通过这种方式:

if ((userOldPass==oldPass) && (newPass==comfirmNewPass))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM