Custom Client-Side Validation

Custom Client-Side Validation

Implement any custom validation logic in the onSelect callback. This example rejects files with spaces in the name and requires a naming convention.

AjaxUploader.create(element, {
    onSelect: function (file) {
        if (/\s/.test(file.name)) {
            alert('Filenames must not contain spaces.');
            return false;
        }
        if (!/^[a-zA-Z]/.test(file.name)) {
            alert('Filename must start with a letter.');
            return false;
        }
        return true;
    }
});