'Weird JS flow in firefox
My JS code is as follows
if (fileControl != NoFileMessage) {
if (fileControl.val() != NoFileMessage) {
var valid_extensions = /(.xlsx)$/i;
if (!valid_extensions.test(fileControl.val())) {
alert($("#txtInvalidFileFormatMsg").val());
return false;
}
...
}
}
During first execution the alert is shown and then the control "jumps back" to the first if statement instead of continuing to return false, due to which the code is executed twice and the alert is shown twice
Due to this, the alert box is shown twice. Any pointers on how I can fix this? It's working fine in other browsers (including IE !)
UPDATE:
Some more insight, this piece of code is being called on the .change() event of a <input type='file />'
As I've stated earlier, the code snippet is executed twice, after some digging in, I figured out that the .change() event is being fired twice. Why does this happen in FX only?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
