<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?>')" >
I have these on my code.
I can’t show the result of these ifs simultaenously.
if(x != cur_p)
and
if(new_p != con_p)
if I place the
if(x != cur_p){}
at the top of
if(new_p != con_p){}
the response result of if(x != cur_p) will show and the latter will not
and vice versa.
how can i show the result of those two ifs
(assuming that the condition for those were meet)
First you have a typo in your code
Second, of course if you return, it exits the function. So the code will not execute both statements.
Change
to