File: /home/awaldron/www/archive/blueliner/include/js/unobtrusive-validation/hidden/submitvalidate.js
//Created By: Chris Campbell
//www.particletree.com
var gErrors = 0; //number of errors is set to none to begin with
function validate()
{
var tables; //variable which will become an array holding all elements with the td tagname
// store all <td> elements in the tables array
tables = document.getElementsByTagName('td')
//loop through all the <td> elements
for (i=0; i<tables.length; i++)
{
// if the class name of that td element is rules check to see if there are error warnings
if (tables[i].className == "rules")
{
//if there is a thank you or its blank then it passes
if (tables[i].innerHTML == 'Thank You' || tables[i].innerHTML == '' )
{
tables[i].style.color = '#000000';//the color is changed to blank or stays black
}
else
{
gErrors = gErrors + 1; //the error count increases by 1
tables[i].style.color = '#ff0000';//error messages are changed to red
}
}
}
if (gErrors > 0){
//if there are any errors give a message
alert ("Please make sure all fields are properly completed. Errors are marked in red!");
gErrors = 0;// reset errors to 0
return false;
}
else
{
alert("The Form Is Valid!");
return false;//set this to true in practice to allow the form to submit
}
}