如果单击该按钮,则验证组件是否为空并且显示错误。
因此:
$("#btnEnvoyer").click(function () {
effacerAnomalie("erreurs");
var ano = 0;
if ($("input[name=prenom]").val() == "") {
showAnomalie('erreurs', "<%=ReferenceMessages.CONTACT_SAISIE_PRENOM%>");
ano++;
}
if ($("input[name=nom]").val() == "") {
showErros('erreurs', "<%=ReferenceMessages.CONTACT_SAISIE_NOM%>");
ano++;
}
});
在我测试是否有以下错误之后:
if ( ano < 1 ) {
// continue for submit button
} else {
// do nothing and the errors messages must be kept
}
我的错误是当我遇到错误(ano> = 1)时,我的表单提交(发布)并清除错误消息。
我不知道为什么
您是否尝试过这样的事情:
$("#btnEnvoyer").click(function (event) {
event.preventDefault();
effacerAnomalie("erreurs");
var ano = 0;
if ($("input[name=prenom]").val() == "") {
showAnomalie('erreurs', "<%=ReferenceMessages.CONTACT_SAISIE_PRENOM%>");
ano++;
}
if ($("input[name=nom]").val() == "") {
showErros('erreurs', "<%=ReferenceMessages.CONTACT_SAISIE_NOM%>");
ano++;
}
if ( ano < 1 ) {
$("yourForm").submit();
} else {
// do nothing and the errors messages must be kept
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句