javascript - Image filename and path validation is not working in Firefox but working in Chrome -
this image filename , path validation code works in chrome not in firefox. shows validation error if upload correct image file. can make code work in firefox?
function add_img(f) { z = f; img_title = $('#img_title' + f + '').val(); img_path = $('#img_path' + f + '').val(); img_desc = $('#img_desc' + f + '').val(); if (img_title == '' || img_path == '') { alert('please upload valid image title.'); return false; } var uploadcontrol = img_path; var reg = /^(([a-za-z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+ (.jpeg|.jpeg|.gif|.gif|.png|.png|.jpg|.jpg)$/; if (uploadcontrol.length > 0) { //checks control value. if (!reg.test(uploadcontrol)) { alert("only jpg,jpeg,gif,png files allowed!"); return false; } } }
i don't think there difference in regex implementation across browsers. possibility not getting full path check against in firefox , getting in chrome. can try console.log(uploadcontrol)
check path received in 2 browsers. may firefox doesn't give drive letter expect , hence doesn't pass regex test.
Comments
Post a Comment