Мне очень надоело проверять форму с помощью jQuery на ASP.NET MVC с помощью Telerik.
Я попробовал все ..... и я не понимаю, что я сделал не так.
Я попробовал последние версии валидаторов jQuery и jQuery, но все равно не работает.
</p>
<p></p>
<pre><code>$(document).ready(function () {
$("#customerForm").validate({
rules: {
CustomerEnShortName:"required"
},
messages: {
CustomerEnShortName: "<li>Please enter a name.</li>"
}
});
});
Код Telerik MVC:
<% 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>