Checking file input type with mootools in joomla

Does anyone know how to check the input type of a file using mootools. I want to check the file type and file size.

window.addEvent('domready', function() {
    document.formvalidator.setHandler('file',
        function (value) {
            if (value.length == "") {
                return false;
            }

            var parts = value.split('.');
            ext = parts[parts.length - 1];
            // check file type is valid as given in 'exts' array
            if (!(ext=='pdf' || ext=='doc' || ext=='docx')){
                return false;
                alert(ext);
            }
            var fsize = value.files[0].size;

            if(fsize>2097152)
            {
            return false;
               alert(fsize);
            }
        return true;
    });
 });

      

The first check works, but the other two do not.

+3


source to share





All Articles