Does the upload control work with validation?

8 posts, 1 answers
  1. Todd
    Todd avatar
    13 posts
    Member since:
    Dec 2011

    Posted 04 Jan 2012 Link to this post

    I am trying to use the validator with the upload control and even though I have selected a file, the validation is returning false. Attached is the source and the image.

  2. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 06 Jan 2012 Link to this post

    Hi,

    I'm afraid that the KendoUpload is currently not support out-of-the-box by the KendoValidator. However, you may workaround this limitation by supplying a custom validation rule similar to the following:

     

    Regards,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Eric
    Eric avatar
    21 posts
    Member since:
    Mar 2012

    Posted 29 Aug 2012 Link to this post

    The solution doesn't seem to be working for me. Has something possibly changed recently with the structure of the upload widget that would be causing the function to never try to validate an input with a type of file?
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 30 Aug 2012 Link to this post

    Hi Eric,

    I'm afraid that I'm unable to observe such issue with the sample. Here is an version of the jsFiddle with updated to the latest version of KendoUI scripts, maybe I'm missing something.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Eric
    Eric avatar
    21 posts
    Member since:
    Mar 2012

    Posted 30 Aug 2012 Link to this post

    Thanks for taking the time to create a new sample. It was actually a problem on my end. I had the required attribute applied to the Upload widget which was causing it to always see it as invalid. Once I removed the required attribute it worked like it did in your sample. Thanks again.
  7. David
    David avatar
    3 posts
    Member since:
    Oct 2012

    Posted 15 Oct 2012 Link to this post

    This makes the warning show already when a user selects a file. And then it doesn't go away when the file is selected. Not until the send/save/submit button is clicked...
    Is there any solution for this?
  8. David
    David avatar
    3 posts
    Member since:
    Oct 2012

    Posted 15 Oct 2012 Link to this post

    Seems to work better when adding:

    $("form .k-upload-button").on("change", "input[type=file]", function () {
        $(this).blur().focus();
    });
  9. Andy F.
    Andy F. avatar
    42 posts
    Member since:
    May 2006

    Posted 19 Sep in reply to Rosen Link to this post

    Coming back to this, the example is missing a test to see if the file passed its own upload widget validation (e.g., allowedExtensions).

    upload: function(input) {
        if (input[0].type == "file" && isNew) {
            return (input.closest(".k-upload").find(".k-file").length > 0 && input.closest(".k-upload").find(".k-file-invalid").length == 0);
        }
        return true;
    }

Back to Top
Kendo UI is VS 2017 Ready