I'm running a script on a form and it's not stopping the submission when it detects one of the cases and the variable is changed. It changes the classes and then submits/resets the form...any help?
Code:
function Check()
{
//get the form fields
var username = document.getElementById('username');
var password1 = document.getElementById('password1');
var password2 = document.getElementById('password2');
var email = document.getElementById('email');
var lname = document.getElementById('lname');
var fname = document.getElementById('fname');
var food = document.getElementById('food');
var sport = document.getElementById('sport');
var interest = document.getElementById('interest');
var good=1;
//validate
if (username.value == "")
{username.className = "invalidbox";
good=0;}
if (email.value == "")
{email.className = "invalidbox";
good=0;}
if (fname.value == "")
{fname.className = "invalidbox";
good=0;}
if (lname.value == "")
{lname.className = "invalidbox";
good=0;}
if (food.value == "")
{food.className = "invalidbox";
good=0;}
if (sport.value == "")
{sport.className = "invalidbox";
good=0;}
if (interest.value == "")
{interest.className = "invalidbox";
good=0;}
if (password1.value == "")
{password1.className = "invalidbox";
good=0;}
if (password2.value == "")
{password2.className = "invalidbox";
good=0;}
if (password1.value!=password2.value)
{password1.className = "invalidbox";
password2.className = "invalidbox";
good=0;}
if (good=0)
{return false;}
if (good=1)
{return true;}
}