2012-01-18 8 views
1

カスタムバリデータを使用してDIVフォームを検証し、検証エラーがなければ閉じるようにしています。以下は私のコードですが、私はカスタムバリデーターを動作させることができません。私がサブミットをクリックすると何も確認せず、何が間違っているのかわかりません。ご意見をお聞かせください。ありがとう。asp.net +カスタムバリデータが検証されない

function validateRedemptionDialog(src, args) { 

       var rDate = document.getElementById('<%=uitxtRedemptionDate.ClientID%>').value; 


       if (rDate == "") { 
        args.IsValid = false; 
        return; 
       } 
       args.IsValid = true; 
      } 


function closeRedemptionDialog() { 
      $('#dialog_Active_Redemption_confirm').dialog('close'); 
     } 

<div id="dialog_Active_Redemption_confirm" style="display: none"> 
       <div class="section_body"> 
        <div class="section_body_content"> 

         <div class="row"> 
          <asp:Label runat="server" ID="uilblRedemptionDate" Text="<%$ Resources:MembersNContactsManagerResources, uigrdhdrTransDate %>" 
           CssClass="label"> 
          </asp:Label> 
          <asp:TextBox ID="uitxtRedemptionDate" runat="server" CssClass="text DatePicker" Style="width: 120px; 
           margin-right: 2px;"> 
          </asp:TextBox> 
         <asp:CustomValidator ID="ctvtxtCamDateEnd" runat="server" ClientValidationFunction="validateRedemptionDialog" 
         ControlToValidate="uitxtRedemptionDate" ErrorMessage='<img src="../Images/icons/error.png" style="vertical-align:middle"/> XXX!' 
         Font-Names="arial" Font-Size="X-Small" SetFocusOnError="True" Display="Dynamic" /> 
         </div> 

         <div class="row"> 
          <asp:Label runat="server" ID="uilblRedemptionAmountSpent" Text="<%$ Resources:MembersNContactsManagerResources, uilblRedemptionAmountSpent %>" 
           CssClass="label"> 
          </asp:Label> 
          <asp:TextBox ID="uitxtRedemptionAmountSpent" runat="server" Style="width: 120px;"> 
          </asp:TextBox>   

         </div> 
         <div class="row"> 
          <ul class="inline" style="margin-left: 137px; padding: 3px;"> 
           <li><span class="button grey_btn"> 
            <%--Submit button--%> 
            <asp:Button ID="uibtnRedemption" runat="server" Text="<%$ Resources : MembersNContactsManagerResources, uilblSubmit %>" OnClientClick="javascript:closeRedemptionDialog();"/> 
            <span>&nbsp;</span> </span></li> 
          </ul> 
         </div> 
        </div> 
       </div> 
      </div> 

答えて

3

バリデータは、現在の設定で空のテキストを検証しません。 ValidateEmptyTexttrueに設定すると、ユーザーが何も入力しなくても起動する必要がある場合。

CustomValidatorはControlToValidateを持つ必要はありません。いずれにしても検証が必要な場合は、そのプロパティを空のままにしてください。

関連する問題