简体   繁体   中英

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

oldPass //from database, user's old password

newPass //from user input, user's new password

confirmNewPass //from user input, user's new password confirmation

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. I used the CryptoJS.SHA1 function I found in the net. 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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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