How can I validate the document uploaded by user and disable the upload button if there is error with the document

Hi,

I need to have a document upload form like this package import form, and have a validate button like inspect button, but I need to disable the import button before the document is validated successfully.

I need to validate the document's content and format, so it's not just a validation for the size and type

How can I do?

  Discussion posts and replies are publicly visible