我在javascript验证中遇到了一些问题 条件是我需要更新文本框中的日期,并且该日期不应该从applicationdate返回,如果我将日期更新为来自applicationdate的backdate,则获取警报masg E-CLRDATELTTXNDATE.issue如果我点击任何文本链接到该日期文本框的框即使我单击此警报窗口的“确定”按钮,此警报也会继续重复。
function txtClearingDate_blur(i) {
i--;
if (document.frmPaymentClearing.hidTxnCount.value == 1) {
if (("" + document.frmPaymentClearing.txtClearingDate.value).length > 0) {
if (!isDate(document.frmPaymentClearing.txtClearingDate.value,document.frmPaymentClearing.hidShortDateFormat.value,document.frmPaymentClearing.hidDateSeperator.value)) {
document.frmPaymentClearing.txtClearingDate.focus();return;
} else {
i++;
if (isClearingDateGreaterThanAppdate(i--)) {
document.frmPaymentClearing.txtClearingDate.focus();
GetAlertMessage("E-CLRDATE","E","","","");
}
i++;
if (!isClearingDateGreaterThanTxnDate(i--)) {
document.frmPaymentClearing.txtClearingDate().focus();
GetAlertMessage("E-CLRDATELTTXNDATE","E","","","");
}
}
}
} else {
if (("" + document.frmPaymentClearing.txtClearingDate[i].value).length > 0) {
if (!isDate(document.frmPaymentClearing.txtClearingDate[i].value,document.frmPaymentClearing.hidShortDateFormat.value,document.frmPaymentClearing.hidDateSeperator.value)) {
document.frmPaymentClearing.txtClearingDate[i].focus();return;
} else {
i++;
if (isClearingDateGreaterThanAppdate(i--)) {
document.frmPaymentClearing.txtClearingDate[i].focus();
GetAlertMessage("E-CLRDATE","E","","","");
}
i++;
if (!isClearingDateGreaterThanTxnDate(i--)) {
document.frmPaymentClearing.txtClearingDate(i).focus();
GetAlertMessage("E-CLRDATELTTXNDATE","E","","","");
return;
}
}
}
}
}
HTML:
<%If strFormState = "NEXTDISPLAY" Then%>
<INPUT type="text" name="txtClearingDate" size=10 value='<%=FormatDateTime(IIF(IsDBNull(rstPaymentRecs.fields.Item("ClearingDate").Value), Nothing, rstPaymentRecs.fields.Item("ClearingDate").Value), 2)%>' onblur="txtClearingDate_blur((<%=i%>))">
<INPUT type="hidden" name="hidTxnDate" size=10 value='<%=FormatDateTime(IIF(IsDBNull(rstPaymentRecs.fields.Item("TransactionDate").Value), Nothing, rstPaymentRecs.fields.Item("TransactionDate").Value), 2)%>'">
<%Else%>
<INPUT type="text" name="txtClearingDate" size=10 value='<%=FormatDateTime(objSecurityContext.Appdate, 2)%>' onblur="txtClearingDate_blur(<%=i%>)">
<INPUT type="hidden" name="hidTxnDate" size=10 value='<%=FormatDateTime(IIF(IsDBNull(rstPaymentRecs.fields.Item("TransactionDate").Value), Nothing, rstPaymentRecs.fields.Item("TransactionDate").Value), 2)%>'">
<%End If%>
答案 0 :(得分:0)
这是因为在警告错误消息之前调用了.focus()
事件。在通知电话后放置它。
字段获得焦点然后在警报时丢失它,模糊事件在未更改的数据上再次触发。