<input id="checkOldPassword" type="button" title="Check New Password" value="Check New Password" onclick="checkPassword()" />
<input id="newPassword" type="text" maxlength="8" min="8" />
<script language="javascript">
function checkPassword()
{
var validString = /^[a-z](?=[a-z]*[0-9])[a-z0-9]{0,6}[a-z]$/;
alert("this worked");
var password = document.getElementById(newPassword).value;
alert(password);
var test = re.test(password);
}
</script>
弹出窗口显示“这有效”正确显示,所以我知道代码正在执行,但 alert(password) 没有弹出键入的密码。我究竟做错了什么?