New to Kendo UI for jQuery? Download free 30-day trial

Validate Selection of Files for Upload


Product Progress® Kendo UI® Upload for jQuery
Operating System All
Browser All
Preferred Language JavaScript


How can I validate if a file is selected for upload when working with the Upload?


Use a custom rule in the Kendo UI Validator to validate on form submission whether a file in the Upload was selected.

    <form id="myForm" action="" enctype="multipart/form-data" method="post">
        <input id="files" name="files" type="file"/>
        <input type="submit" />    


        var fileNotSelected = false;

        var validator = $("#myForm").kendoValidator({
            rules: {
            upload: function(input) {
                if (input[0].type == "file") {
                    fileNotSelected = true;
                    var len = input.closest(".k-upload").find(".k-file").length;

                    return len > 0;

                return true;

        $("#myForm").submit(function(e) {

            if(!validator.validate()) {
                if(fileNotSelected) {
                    alert('Please select file to upload')
                    fileNotSelected = false;                    
In this article