2012-02-07 12 views
2

Telerikを使用してASP.NET MVCでjQueryを使用してフォームを検証しようとするのは本当にうんざりです。Telerik(ASP.NET MVC)を使用したjQueryフォームの検証

私はすべてを試しました.....そして、私は間違ったことを理解していません。

jQueryとjQueryバリデータの最新バージョンを試しましたが、それでも動作しません。

$(document).ready(function() { 

    $("#customerForm").validate({ 

     rules: { 
     CustomerEnShortName:"required" 
    }, 
    messages: { 

     CustomerEnShortName: "<li>Please enter a name.</li>" 
    } 

}); 


}); 

The Telerik MVC code:

<% using (Html.BeginForm("Edit","Customer", FormMethod.Post, new{ id= "customerForm"})) { %> 
<%: Html.ValidationSummary() %> 
    <fieldset> 


<legend>CustomerInfo</legend> 

    <div class="editor-label"> 
     <label id="lblCustomerShortName">Customer Short Name</label> 
    </div> 
    <div class="editor-field"> 
     <%: Html.Telerik().AutoCompleteFor(m =>m.CustomerEnShortName) %> 
    </div> 

    <div class="editor-label"> 
     <label id="lblCustomerFullName" >Customer Full Name</label> 
    </div> 
    <div class="editor-field"> 
     <%: Html.Telerik().AutoCompleteFor(m => m.CustomerEnFullName) %> 
    </div> 



    <div class="editor-label"> 
       <label id="lblCustomerNIN">Customer NIN</label> 
    </div> 
    <div class="editor-field"> 
     <%:Html.Telerik().AutoCompleteFor(m => m.Customer_NIN) %> 
    </div> 





    <div class="editor-label"> 
     <%: Html.Label("Is Active") %> 
    </div> 

    <div class="editor-field"> 
    <% 
     string isActive; 
     if (Model.CustomerActivity == 1) 
      isActive = "true"; 
     else 
      isActive = "false"; 
      %> 
     <input id="IsActive" name="IsActive" type="checkbox" checked="<%= isActive %>" /> 
    </div> 

    <p> 
     <input type="submit" value="Save" /> 
    </p> 
</fieldset> 
<%} %> 

生成される出力コードは次のとおりです。

<form action="/Customer/Edit/31" id="customerForm" method="post"> 
<div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li> 
    </ul></div> 
    <fieldset> 
      <legend>CustomerInfo</legend> 


     <div class="editor-label"> 
     <label id="lblCustomerShortName">Customer Short Name</label> 
    </div> 
    <div class="editor-field"> 
     <input class="t-widget t-autocomplete t-input" id="CustomerEnShortName" name="CustomerEnShortName" type="text" /> 
    </div> 

    <div class="editor-label"> 
     <label id="lblCustomerFullName" >Customer Full Name</label> 
    </div> 
    <div class="editor-field"> 
     <input class="t-widget t-autocomplete t-input" id="CustomerEnFullName" name="CustomerEnFullName" type="text" value="CUSTOMER -31" /> 
    </div>   

    <div class="editor-label"> 
       <label id="lblCustomerNIN">Customer NIN</label> 
    </div> 
    <div class="editor-field"> 
     <input class="t-widget t-autocomplete t-input" id="Customer_NIN" name="Customer_NIN" type="text" value="1559446285" /> 
    </div> 





    <div class="editor-label"> 
     <label for="Is_Active">Is Active</label> 
    </div> 

    <div class="editor-field"> 

     <input id="IsActive" name="IsActive" type="checkbox" checked="true" /> 
    </div> 

    <p> 
     <input type="submit" value="Save" /> 
    </p> 
</fieldset> 
</form> 

+0

telerikコントロールを削除すると機能しますか? – gdoron

答えて

0

場合でもScriptRegistrarからインクルードされるjquery.validateファイルの原因となる新しいリリースで問題が発生しました省略するように指定されています。

これにより、検証が失敗する可能性があります。

this hotfixを使用して問題を解決してください。

関連する問題