Validate a div element

4 posts, 0 answers
  1. Matt
    Matt avatar
    43 posts
    Member since:
    May 2013

    Posted 17 Dec 2013 Link to this post

    I have a two boxes that were previously input elements and are now inline html editors. Can any other element that are not a 'input' element be added onto the validator's list of things to check. The use is in a list view. Or would the only solution be having some hidden elements?
    1.<div class="WebDescriptionEditor" data-bind="value: WebDescription" data-role="editor"
    2.   contentEditable="true"
    3.   data-tools="['bold','italic','underline','strikethrough']">
    4.</div>
    Thats basically it. The work around i have otherwise is to include a hidden input element after each of the the divs as so:
    1.<input type="hidden" name="WebDescription" data-bind="value: WebDescription" />
    Then the custom validation on the datasource iterates through the input elements and validates the above. Any way to skip having the extra html?

    Thanks,
    Matt
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 19 Dec 2013 Link to this post

    Hi Matt,

    Yes, validating div elements is possible using the Validator's validateInput method, as shown in this small example.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. HaBo
    HaBo avatar
    34 posts
    Member since:
    Oct 2011

    Posted 07 Dec 2017 in reply to Alexander Popov Link to this post

    I am trying to validate current tab on selection of other tab and prevent tab active if current tab validation is not passing.

    Here is my code, validation is always coming true

    onSelect: function (e) {
                    var container = $("#work-add-edit-form");
                    kendo.init(container);
                    container.kendoValidator();
                    var validator = $("#work-add-edit-form").kendoValidator().data("kendoValidator");
                    //var tabStrip = $("#work-add-edit-tabstrip").data("kendoTabStrip");
                    //var currentActiveTab = tabStrip.select();
                    //var contentId = currentActiveTab[0].getAttribute("aria-controls");
                    if (!validator.validateInput($(".k-tabstrip .k-content.k-state-active"))) {
                        e.preventDefault();
                    }
                }
  4. Joana
    Admin
    Joana avatar
    210 posts

    Posted 11 Dec 2017 Link to this post

    Hi Harsha,

    I have prepared a sample dojo based on your requirements and code: https://dojo.telerik.com/imACEF. The code you have provided looks good. Make sure that the validation attributes and the selector for the input that is to be validated are correct.

    Let me know if I have missed something in your scenario. You could update the dojo sample to match your case and send it back to us for examination.

    Regards,
    Joana
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top