This regx does not work only in Chrome

Posted by Deeptechtons on Stack Overflow See other posts from Stack Overflow or by Deeptechtons
Published on 2011-01-04T10:43:25Z Indexed on 2011/01/04 10:53 UTC
Read the original article Hit count: 310

Filed under:
|
|
|
|

Hi i just put up a validation function in jScript to validate filename in fileupload control[input type file]. The function seems to work fine in FF and sometimes in ie but never in Chrome. Basically the function tests if File name is atleast 1 char upto 25 characters long.Contains only valid characters,numbers [no spaces] and are of file types in the list. Could you throw some light on this

function validate(Uploadelem) {
    var objRgx = new RegExp(/^[\w]{1,25}\.*\.(jpg|gif|png|jpeg|doc|docx|pdf|txt|rtf)$/);
    objRgx.ignoreCase = true;
    if (objRgx.test(Uploadelem.value)) {
        document.getElementById('moreUploadsLink').style.display = 'block';
    } else {
        document.getElementById('moreUploadsLink').style.display = 'none';
    }
}

© Stack Overflow or respective owner

Related posts about regex

Related posts about file