I was told that this code is leaking a1,a2,a3 in this previous post
function t1()
{
var a=document.forms['f1'].elements;
a1="Please fill out all fields";
a2="Please enter your name using only letters and dashes";
a3="Please enter a valid email address";
a4="Password must be atleast 6 characters";
if(c0(a,a1,'fb2')&&c1(a,a2,'fb2')&&c2(a[2],a3,'fb2')&&c3(a[3],a4,'fb2'))
{
return 1;
}
else
{
return 0;
}
}
It appears that in the previous post, “leaking” referred to the fact that the variables
a1througha4are not declared correctly in the scope of the functiont1(). Without avarkeyword, they become global variables.You might have intended to end each of those lines with a comma
,instead of a semicolon;, which would chain them all into a single statement sharing the firstvarkeyword. In that case, they would not have become global. Just be sure to terminate the last one with;. However, I think it is more readable and better practice to keep each as its own statement as I’ve done above.There are lots of blog posts out there about JS variable leaks. Here’s one I just found to get you started…