$(‘#Password’).val() returns undefined [on hold]

I’m trying to validate if my password and confirm password fields values are mtaching, but when I use $('#Password').val() it returns undefined.

My field is implemented like follows:

<input class="form-control text-box single-line input-validation-valid" id="Passowrd" name="Passowrd" type="password" value="">

问题评论:

1
You have a type. Passowrd != Password`
3
typo error “Passowrd”
There is no element in your HTML with the id value "Password".

答案:

答案1:

You have a typo in your id and name properties for <input>, passowrd should obviously be password.

var password = $('#password').val();
console.log(password);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="form-control text-box single-line input-validation-valid" id="password" name="password" type="password" value="test">

答案评论:

原文地址:

https://stackoverflow.com/questions/47757076/password-val-returns-undefined

添加评论

友情链接:蝴蝶教程