开发者

Problem in indexOf in javascript

开发者 https://www.devze.com 2023-01-14 21:59 出处:网络
I want to find out if a variable value contains in second string. My code is if (ext.indexOf(FileUploadval.substring(FileUploadval.lastIndexOf(\'.\') + 1)) == -1) {

I want to find out if a variable value contains in second string. My code is

if (ext.indexOf(FileUploadval.substring(FileUploadval.lastIndexOf('.') + 1)) == -1) {
}

where ext have va开发者_StackOverflow社区lue pdf,doc,dox,xls,xlsx,ppt,pptx and when i try xls or xlsx file it goes in if condition but when i try doc or pdf it doesnot go in if condition. what can be the problem?


Maybe case sensitive


Check the case of the file extensions (UPPER vs lower vs miXeD)


Try the following:

if (ext.indexOf(FileUploadval.toLowerCase().substring(FileUploadval.toLowerCase().lastIndexOf('.') + 1)) == -1) {
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号