I want to create an aspx file where I will have a tab to upload a file in SharePoint Online library. On upload, I want to check whether the file title is having the correct format or not. If file is not having the right format, I have to request user to check for the format. So, can some one help me with this?


Sample regex for file type validation, hope it would help you.

// Get test values from the file input and text input page controls.
        var fileInput = jQuery('#getFile');
        var newName = jQuery('#displayName').val();

        var parts = fileInput[0].value.split('\\');
        var fileName = parts[parts.length - 1];
        var fileRegex = new RegExp('\.[^.\\/:*?"<>|\r\n]+$');
        var fileType = fileName.match(fileRegex)[0];

You could use official demo to upload file(above test demo is based on official demo also).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.