2011-03-16 85 views
0

我在JavaScript验证中遇到了一些问题 条件是我需要更新文本框中的日期,并且该日期不应该从applicationdate反向,如果我更新日期作为applicationdate的backdate生病获取警报masg E-CLRDATELTTXNDATE.issue是,如果我点击任何文本框链接到该日期文本框,即使我点击这个警报窗口的确定按钮,这个警报继续重复。javascript验证

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

这是因为.focus()事件提醒你的错误消息之前调用。将其置于警报呼叫之后。

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

+0

嗨,Thanx为你提供宝贵的答案。我试着通过改变.Focus后警告味精,仍面临同样的问题,你可以建议我一些解决方案来纠正这个问题。 – Bargavi 2011-03-16 06:36:28

+0

尝试将所有'.focus()'实例注释掉,看它是否会以您需要的方式运行。然后add'em回来一个接一个 – 2011-03-16 06:42:34

+0

好吧,我会试试看,并得到你回:-) – Bargavi 2011-03-16 06:49:46