Check password - Where is the error in code?

前端 未结 3 703
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 08:06

The password authentication code, but does not work.. Where is the error in my code?

JS:

function checkPass() {
var pass = document.getE         


        
3条回答
  •  滥情空心
    2021-01-28 08:10

    First, you are trying to compare two input elements, and not their values. You need to access their value properties. You should also use the strict comparison operator where possible.

    if ( pass1.value !== pass2.value )
    

    Second, you are trying to use document.layers, which is a proprietary property seen in Netscape 4.

    You need a more modern guide, try the W3C's JavaScript core skils, the section on Traversing the DOM covers the area you are dealing with (but if you have been working with guides that mention layers you are likely to benefit from starting at the beginning).

提交回复
热议问题