Edit this page

Display Validation Messages with Templates

When the Upload is configured to use a template, the content of the template replaces some of the HTML elements of the widget that are rendered by default.

The following example demonstrates how to add a span element to the template. This allows a validation message to be conditionally displayed.

<div id="example">
    <input name="files" id="files" type="file" />
    <div class="demo-hint">You can only upload <strong>PDF</strong> files.</div>

    <script id="fileTemplate" type="text/x-kendo-template">
        <span class='k-progress'></span>
        <div class='file-wrapper'>
            <h4 class='file-heading file-name-heading'>Name: #=name#</h4>
            <h4 class='file-heading file-size-heading'>Size: #=size# bytes</h4>
            <span class='validation-message #=files[0].extension == ".pdf" ? "hide" : "show"#'>#=files[0].extension# file type not allowed. </span>
            <button type='button' class='k-upload-action'></button>

        $(document).ready(function () {
                async: {
                    saveUrl: "save",
                    removeUrl: "remove"
                validation: {
                    allowedExtensions: [".pdf"]
                template: kendo.template($('#fileTemplate').html())
        .hide {
            display: none;

        .show {
            display: inline;

        .validation-message {
            color: red;

See Also

For more runnable examples on the Kendo UI Upload widget, browse its How To documentation folder.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve the information