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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -