Hi Guys,
I am stumped by this javascript. It is supposed to validate and submit a form. When I click submit with fields left out, it throws the error I set. However, when everything is right the form won't submit. How do I fix this? THANKS!
I am stumped by this javascript. It is supposed to validate and submit a form. When I click submit with fields left out, it throws the error I set. However, when everything is right the form won't submit. How do I fix this? THANKS!
Code:
function validate()
{
var error=document.getElementById("errors")
var okay=document.getElementById("okay")
var form=document.getElementById("form1")
var text=document.getElementById("text")
var freq=document.getElementById("freq")
var call=document.getElementById("callsign")
var msg=document.getElementById("msg")
var btn=document.getElementById("submit")
good="yes"
if (text.value.length<3)
{
alert("text error")
text.className="formError"
good="no"
}
if (freq.value.length<4)
{
alert("frequency error")
freq.className="formError"
good="no"
}
if (call.value.length<2)
{
alert("callsign error")
call.className="formError"
good="no"
}
if (good=="yes")
{
form.submit()
}
}