I am an issue with my javascript calling valid extensions invalid when they should pass. Ive used this regular expression in server side code and it worked fine for me.
I verified that the value the reg expression is checking against is valid as well.
Am I declaring reg expression wrong maybe in the javascript?
var ck_name = /^.+\.((gdf)|(GDF))$/;
var chldValue = chld.value.substring(chld.value.length - 4, chld.value.length);
alert(chldValue);
if (!ck_name.test(chldValue)) {
errors[errors.length] = "File is NOT a GDF file";
}
Firstly,
^.+is unnecessary and timewasting.Second, your string is only four character long and what you are looking for… is a minimum of five characters long. Consequently they will never match.
Third, a regex is overkill.
Finally, your code should be: