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
mootools joomla validation


source to share


No one has answered this question yet

Check out similar questions:

3998
How to validate an email address in JavaScript
3175
How do I validate an email address using a regular expression?
2303
Checking decimal numbers in JavaScript - IsNumeric ()
1012
(Inline) way in JavaScript to check if a string is a valid number
839
Full regex to validate phone number
812
What is the maximum length of a valid email address?
515
Prompt the user for input until they give a valid answer
2
Overriding the validation check message
2
validating multiple inputs using jquery
0
File type check! for generated input file tag elements



All Articles
Loading...
X
Show
Funny
Dev
Pics