Validate form fields using javascript on jsp page
I am trying to validate form fields on a jsp page using javascript. When I try to use the code below, it gives me an error that the field is undefined and never goes into the javascript. Is there something that has to be set for the javascript to get the field values, or is the syntax different for jsp than other languages (i.e. Coldfusion - html)???
<form name="form_data" action="form_data_save.jsp" method="get" onSubmit="return check_data();">
function check_data()
{
if(document.form_data.need_date.value= "")
{
alert("You must enter a date");
return false;
}
else
{
return true;
}
}