This is a migrated thread and some comments may be shown as answers.

Validate a div element

3 Answers 697 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 17 Dec 2013, 02:19 PM
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

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 19 Dec 2013, 09:23 AM
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!
0
HaBo
Top achievements
Rank 1
answered on 07 Dec 2017, 05:25 PM

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();
                }
            }
0
Joana
Telerik team
answered on 11 Dec 2017, 12:32 PM
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.
Tags
Validation
Asked by
Matt
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
HaBo
Top achievements
Rank 1
Joana
Telerik team
Share this question
or