how to validate excel files
My JQuery
jQuery("#excel").validate({
expression: "if (VAL.match(/^([a-z]\w*)\.(xls[mx]?)$/) && VAL) return true; else return false;",
message: "Please upload valid excel file"
});
how to validate excel files
My JQuery
jQuery("#excel").validate({
expression: "if (VAL.match(/^([a-z]\w*)\.(xls[mx]?)$/) && VAL) return true; else return false;",
message: "Please upload valid excel file"
});
First of all, you should change an order in expression, since you don’t want to execute expression on invalid
VAL
:Secondary, any
\w
symbol is perfectly valid as starting symbol for filename, as well, as a dot and space (and, possibly, some other symbols.) Dots in regexps should be escaped. And, a last but not least, you could want to compact thexls*
s:You need to escape the dots.
OR
[mx]?
matches an optionalm
orx
Use this regex if you want to allow any characters inbetween
^([a-z].*)\.(xls[mx]?)$