Hello,

I have my form, and my JavaScript validating it, it was working great until I decided to add a textarea field. I am missing something, I am new with JavaScript so any help would be very appreciated!

Thanks in advanced to whomever helps me with this


----
HTML

<form action="FormtoEmail.php" method="post" name="contactForm" onsubmit="return ValidateForm()">

<label>Your Name</label><input class="reqname" value="" type="text" name="name" />

<label>Your Email</label><input class="reqemail" value="" type="text" name="email" />

<label>Message</label><textarea class="reqquestion" value="" name="message" rows="6" cols="29"></textarea>

<input type="image" src="images/button_iamdone.png" alt="submit" name="submit" value="send" />

</form>


----
JavaScrypt

function validateForms()
{
var elementsForms;

if (!document.getElementsByTagName) return false;
elementsForms = document.getElementsByTagName("form");
for (var intCounter = 0; intCounter < elementsForms.length; intCounter++)
{
return validateForm(elementsForms[intCounter]);
}
}

function validateForm(currentForm)
{
var blnvalidate = true;
var elementsInputs;

elementsInputs = currentForm.getElementsByTagName("input");

for (var intCounter = 0; intCounter < elementsInputs.length; intCounter++)
{
if (elementsInputs[intCounter].className == "reqquestion")
{
if (validateText(elementsInputs, intCounter))
{
blnvalidate = false;
alert("You have not let us know how can we help you");
}
}
else if (elementsInputs[intCounter].className == "reqemail")
{
if (validateEmail(elementsInputs, intCounter))
{
blnvalidate = false;
alert("Please insert a valid email");
}
}
else if (elementsInputs[intCounter].className == "reqname")
{
if (validateName(elementsInputs, intCounter))
{
blnvalidate = false;
alert("Please insert a valid name");
}
}
}
return blnvalidate;
}

function validateName(elementsInputs, intCounter, strErrorMessage)
{
if (elementsInputs[intCounter].value == "")
{
return true;
}
}
function validateEmail(elementsInputs, intCounter)
{
var emailFilter=/^.+@.+\..{2,3}$/;
if (!emailFilter.test(elementsInputs[intCounter].value))
{
return true;
}
}
function validateText(elementsInputs, intCounter, strErrorMessage)
{
if (elementsInputs[intCounter].value == "")
{
return true;
}
}
function applyOnSubmitToForms()
{
elementsForms = document.getElementsByTagName("form");
for (var intCounter = 0; intCounter < elementsForms.length; intCounter++)
{
elementsForms[intCounter].onsubmit = function ()
{
if (!validateForms())
{
return false;
}
}
}
}
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function()
{
oldonload();
func();
}
}
}

addLoadEvent(applyOnSubmitToForms);