这是我的脚本:
<script>
$('.change_password_button').click(function() {
var error = [];
if (!$('.password').val()) {
error[0] = "Current password field is empty.";
}
if (!$('.new_password').val()) {
error[1] = "New password field is empty.";
}
if (!$('.confirm_password').val()) {
error[2] = "Confirm password field is empty.";
}
if ($('.new_password').val() != $('.confirm_password').val()) {
error[3] = "Your new password and confirm password fields do not match.";
}
for (var i = 0; i < error.length; i = i + 1) {
$('#errors').show();
$('#errors').html(error[i]);
}
});
</script>
我想显示一次发生的所有错误,但现在它只显示一条错误消息。提前感谢您的回答。