Read-only fields not being validated

2 posts, 1 answers
  1. eduardo
    eduardo  avatar
    7 posts
    Member since:
    Jul 2012

    Posted 13 Dec 2012 Link to this post

    I just updated to the latest version of Kendo UI for ASP.NET MVC (Q3 2012).
    I noticed that some text boxes with both "required" and "readonly" attributes are not being validated anymore.
    Here's what I have:

       var materialHtmlAttributes = new Dictionary<string, object>();
       materialHtmlAttributes.Add("class", "k-textbox");
       materialHtmlAttributes.Add("readonly", "readonly");
       materialHtmlAttributes.Add("data-bind", "value: item.Material.Description");
       materialHtmlAttributes.Add("validationMessage", "The Material field is required.");
       materialHtmlAttributes.Add("required", "required");
    @Html.TextBox("materialInputText", null, materialHtmlAttributes)

    With the previous version of Kendo UI, this worked fine and the field was validated correctly, even being read-only. Now, this does not work anymore, the field is no longer validated. If I remove the read-only attribute, then it works.
    It is important that the field remains read-only, because the value is set according to a selection made by the user in a list.

    Is there a reason for this to not work anymore? Do I have to make some adjustments?

    Thank you.
  2. Answer
    Daniel avatar
    2110 posts

    Posted 15 Dec 2012 Link to this post

    Hello Eduardo,

    The change is by design and can be seen in the release notes -  Read-only inputs should not be validated. If you need the readonly input to be validated I can suggest to use a custom rule or override the required rule.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top