String password = (String)session.getAttribute("password");
<input type = "password" placeholder = "Type your current password" id = "pass" />
现在,我想将表单字段中的值与变量&#34; password&#34;进行比较。如何使用JavaScript进行此操作?
答案 0 :(得分:0)
这样做
html文件
<input type = "password" placeholder = "Type your current password" id = "pass" />
的script.js
var password="<%session.getAttribute("password");%>";
var pass=document.getElementById('pass').value;
return pass.equals(password);