Validate before upload

2 posts, 0 answers
  1. Angie
    Angie avatar
    113 posts
    Member since:
    Jan 2008

    Posted 27 Nov 2017 Link to this post

    Hello!  I would like to require the user to fill in a textbox before they can select a file for upload.  Is there a javascript event that is fired on the click event of the select input? I want to prevent the file dialog from opening.  

    Thank you!


    <telerik:RadAsyncUpload ID="fuMediaUpload" runat="server" AllowedFileExtensions=".MOV,.mp4,.wmv,.avi,.mpeg,.mpg,.mp3,.aac,.m4a"
                           EnableInlineProgress="true" MaxFileInputsCount="1" ControlObjectsVisibility="None" DisableChunkUpload="false"  Skin="Bootstrap"
                           MaxFileSize="629145600" ChunkSize="10485760" OverwriteExistingFiles="true" RenderMode="Lightweight" HideFileInput="true" localization-select="Select Media File"
                           OnClientFileUploadRemoved="OnClientFileUploadRemoved" OnClientFileUploaded="OnClientFileUploaded"  EnableViewState="true"  >


  2. Peter Milchev
    Peter Milchev avatar
    804 posts

    Posted 01 Dec 2017 Link to this post

    Hello Angie,

    I am pasting the reply from the support thread here for convenience and better visibility from the community.

    The OnClientFilesSelected event handler can contain the validation and if the validation failed, you can cancel the upload of the selected files. One possible issue that may arise when validating before the file is uploaded is if the textbox is cleared while the file is being uploaded.

    Another possible option is to use the Manual Upload functionality and not allow the files to be uploaded before filling the textbox. The AsyncUpload - Control over Upload Process demo shows how to use the Manual Upload. 

    A third possible option is to conditionally set the button as a Postback Trigger when the Textbox is not empty as described in Dynamically change the PostbackTriggers collection of the AsyncUpload.

    Peter Milchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top