I have a form, and my JS is validating input upon submission. I have some test data that should only appear in the console if 'test=true' is in the query string. However this data is showing up despite that not being the case in some browsers.
Works: FF; Does not work: Chrome, IE
$.each($(".required"), function(){
var test = false;
if($.contains(location.search.toString(),"test=true")){
console.log("test activated");
console.log("location.search: ",location.search);
console.log("test: ",test)
test = true;
}
console.log("test after: ",test);
if(test){console.log("---- ", $(this).attr("name"), "---- ");}
}
Here's the output:
test activated
location.search:
test: false
-------------- fname ------------
As you can see, location.search is nothing and 'test' is equal to false, so nothing should be logged, right? Am I missing something here?