Bug report
Remote Validator Not Blocking Form Submission
Reproduction of the problem
Project attached
Expected/desired behavior
Form submission shall trigger after the validation has completed
Environment
Kendo UI version: [all]
Browser: [all]
Feature Request
Create TexBox label from ViewModel Data Annotation
Currently, this is possible using the default @Html.Label, and @Html.Textbox
-Model:
[DisplayName("First Name :")]
public string FirstName { get; set; }
-View
<tr> <td> @ Html.LabelFor(m=>m.FirstName) </td> <td> @Html.TextBoxFor(m=>m.FirstName) </td> </tr>
Data Model
[Required]
[StringLength(128)]
[DisplayName("Password")]
[DataType(DataType.Password)]
public string UserPassword { get; set; }
<div class="form-group">
<kendo-textbox name="UserPassword" type="password"> <!-HOW to use DataType Annotation here? -- >
<textbox-label content="@Html.DisplayNameFor(m=>m.UserPassword)" floating="true" />
</kendo-textbox>
</div>
The solution below can be used as a workaround for the time being:
@{ Dictionary<string, string> fieldTypes = new Dictionary<string, string>();
var properties = typeof(TestModel).GetProperties();
foreach (var property in properties)
{
var dataTypeAttributes = property.GetCustomAttributes(
typeof(System.ComponentModel.DataAnnotations.DataTypeAttribute), false);
if (dataTypeAttributes.Length > 0)
{
var attribute = dataTypeAttributes[0] as
System.ComponentModel.DataAnnotations.DataTypeAttribute;
var dataType = (System.ComponentModel.DataAnnotations.DataType)attribute.DataType;
fieldTypes[property.Name] = dataType.ToString().ToLowerInvariant();
}
else
{
fieldTypes[property.Name] = null;
}
} }
<form id="mainForm" kendo-validator="true">
<kendo-textbox for="UserPassword" type="@fieldTypes["UserPassword"]">
<textbox-label content="@Html.DisplayNameFor(m=>m.UserPassword)" floating="true" />
</kendo-textbox>
</form>
<script>
$(document).ready(function () {
var validator = $("#mainForm").data("kendoValidator");
});
</script