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

Do not show files that fail validation

2 Answers 102 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Baal
Top achievements
Rank 1
Baal asked on 15 Oct 2012, 07:05 PM


In the above example, even though the second file Lighthouse.jpg fails validation, it in the file list. Although the green and red bullet show the status of each file, it is not as intuitive, especially if you select multiple at a time. Firstly you have to scan through the list to see which all failed. Secondly colourblind people can have a hard time distinguishing them.

How can I make it so that files that fail validation don't show up there? I'm planning to have a error area below the upload control that will list files that fail validation and only show validated files up there.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Bruce
Top achievements
Rank 1
answered on 15 Oct 2012, 07:46 PM
This is how I did it:
function OnClientValidationFailed(sender, args) {
            var allowedExtensions = $(".uploadFileExtensions").html();
            alert('Sorry but that file extension is not allowed. Only the following file extensions are allowed ' + allowedExtensions);
 
            var upload = document.getElementById('<%=radUpload.ClientID %>');
            var index = $(args.get_row()).index();
            sender.deleteFileInputAt(index);
        }


Make sure you set the OnClientValidationFailed event up on the control:
<telerik:RadAsyncUpload ID="radUpload" runat="server" AllowedFileExtensions="pdf,jpeg,jpg,png,ppt" OnClientValidationFailed="OnClientValidationFailed" />
0
Baal
Top achievements
Rank 1
answered on 15 Oct 2012, 08:22 PM
Thanks Bruce. It works wonderfully.
Tags
AsyncUpload
Asked by
Baal
Top achievements
Rank 1
Answers by
Bruce
Top achievements
Rank 1
Baal
Top achievements
Rank 1
Share this question
or