<script language="JavaScript">
function validate(x) {
var cur_p = document.getElementById('current').value;
var new_p = document.getElementById('new').value;
var con_p = document.getElementById('confirm').value;
document.getElementById('msg_p').innerHTML = '';
document.getElementById('msg_cur').innerHTML = '';
if(x != cur_p)
{ document.getElementById('msg_cur').innerHTML = ' Your password was incorrect';
return false;
}
if(new_p != con_p)
{ document.getElementById('msg_p').innerHTML = 'Passwords do not match';
return false;
}
return (true);
}
</script>
HTMLJavaScript不能同时工作
<form action='change-password.php' method='post' onsubmit="return validate('<?=$current?>')" >
我有这些对我的代码。 我无法同时显示这些ifs的结果。
if(x != cur_p)
and
if(new_p != con_p)
如果我放置
if(x != cur_p){}
在
if(new_p != con_p){}
如果响应结果顶端(X!= cur_p)将显示,而后者不会
,反之亦然。
我该怎么让这两个IFS (假设这些条件都满足)
'HTM'中缺失的'L'不是我猜测的原因。 但你的第二个解决方案是伟大的。 非常感谢你@epascarello你节省了我的一天 –