This is my script (simplified):
var $error = false;
//Check for errors
$('.required').each(function()
{
var $error = true;
});
alert($error);
How to make the above code return true in the alert function? The each function is executed 3 times at my page to check for empty fields. But in the above the alert contains false instead of true. Is there a way to parse the variable $error outside the each function to check if there are empty fields after the each loop?