I'm trying to get the validation working on my form with kendovalidator
I'm using Telerik ver : 2019.2.619
$.validator.setDefaults({
ignore: ""
});
$(function () {
$("#form1").kendoValidator();
});
this shows validation messages correctly if values are empty eg:
issue is when an incorrect value is entered the message shows:
<div class="form-group row">
@Html.LabelFor(model => model.CountryCodeId, htmlAttributes: new { @class = "control-label col-md-2 required" })
<div class="col-md-10">
@(Html.Kendo().ComboBoxFor(m => m.CountryCodeId)
.Name("CountryCodeId")
.Placeholder(@Resources.Resources.CountryPlaceholder)
.DataTextField("Description")
.DataValueField("Id")
.Filter("contains")
.Suggest(true)
.DataSource(s => s.Read(r => r.Action("GetCountries", "Customer")).ServerFiltering(false))
.HtmlAttributes(new { style = "width:300px" })
)
@Html.ValidationMessageFor(model => model.CountryCodeId, "", new { @class = "text-danger" })
</div>
</div>
[Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "CountryValidation")]
[Display(ResourceType = typeof(Resources.Resources), Name = "Country")]
public int? CountryCodeId { get; set; }
and if I enter a number the validation seems to pass, which it shouldn't
Validation should pass only if a country is selected from the combobox, entrering a numeric value or any other text which is not on the list should fail validation
How do I get default dataanotation message if an invalid entry is made?
Thanks
Hi Martin
Custom message comes from an xml file, just a key value pair. it wasn't the issue. I removed it replaced it with a string. please see attached doc for details.
Thanks