<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>
html
<form action='change-password.php' method='post' onsubmit="return validate('<?=$current?>')" >
我的代码上有这些。我无法同时显示这些 if 的结果。
if(x != cur_p)
and
if(new_p != con_p)
如果我把
if(x != cur_p){}
在顶部
if(new_p != con_p){}
if(x != cur_p) 的响应结果会显示,后者不会
反之亦然。
我如何显示这两个 if 的结果(假设满足那些条件)