繁体   English   中英

javascript验证

[英]javascript validation

我在javascript验证条件中面临一些问题,我需要更新文本框中的日期,并且该日期不应从applicationdate追溯,如果我将日期从applicationdate更新为backdate,则会收到警告信息masg E-CLRDATELTTXNDATE。问题是,如果我单击链接到该日期文本框的任何文本框,即使单击此警报窗口的“确定”按钮,此警报也会继续重复。

   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%>

这是因为您在警告错误消息之前调用了.focus()事件。 将其放在警报电话之后。

字段接收焦点,然后在警报上失去焦点,对未更改的数据再次触发模糊事件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM