I am facing a strange problem only in chrome. I am trying to set the file input color on onClick
event of a 'Save' button if there is some validation errors for file input. I tried jquery
and simple javascript
to set the color but none of them worked for me. This is a problem only in chrome because I tried in mozilla firefox
and seems to work correctly.
I am using WebForms
and I have a list of file inputs generated from c# code. The code in javascript is as below:
$("input[id^='DC_LVP5EMulti_FU5M_']").each(function (i) {
var index = $(this).attr("index");
//$("#DC_LVP5EMulti_FU5M_" + index).css('color', 'black');
document.getElementById("DC_LVP5EMulti_FU5M_" + index).style.color = "#000000";
});
Something I noticed while debugging in chrome, I set a file input color to red in console
using document.getElementById("DC_LVP5EMulti_FU5M_2").style.color = "red";
statement and it worked but it did not have a file uploaded so the text was 'No file choosen' and after I updated all file inputs text color to black again the only one that did not change was the one that has not the text 'No file choosen' but the name of the file uploaded, so I guess the problem is when an input file contains a file and the text has been changed from 'No file choosen' to file name.
Does anybody faced this strange problem before ?