Skip to content
Advertisement

Validate kendo upload control

I have a user form with a kendo upload control. I need to make sure the upload control has been completed before the user is aloud to submit the form. Uploading a file is just an optional. I will like to have a message to the user if they hit the submit button that lets them know the upload control is still processing. I am thinking of using e.preventDefault on the submit button along with a variable to check if they are still uploading a file. I can set it to false in the upload event and switch it to true in the complete event.

Wanted to see if anyone else had any other ideas?

JavaScript

Advertisement

Answer

When user start upload file or an upload process was finish, there will be an uid (unique ID) for each file upload. So you can store these uid in an array when the upload is start, and remove the uid when the upload was finished. Then control whether user can submit the form based on whether the uid array is empty. Following is the example:

Create an array variable which use to store uploading file’s uid

JavaScript

Assuming you want to disable the submit button when submit form was not allowed

JavaScript

Create a function to add uid to the list

JavaScript

When start upload a file, add the uid to the list and update the button status

JavaScript

Create a function to remove uid from the list

JavaScript

When an upload process was finished, remove uid from the list and update the button status

JavaScript

Demo:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement