jen2483
asked on
Textarea validation.
How can I validate a textarea is not empty? I use the code below, but it doesn't work well. Any suggestion? Thanks.
I use the following html code:
<form method="post" action="/EW/forms/form.jsp " id=formRequest name=Form onSubmit="return form_validator(this)">
<table>
<tr>
<td align="center" colspan="2"><textarea name="comments" rows="6" cols="48"> </textarea></td>
</tr>
</table>
</form>
My javascript:
function form_validator(theForm){
if (theForm.comments.value == ""){
alert("Please provide details.");
theForm.comments.focus();
return (false);
}
return (true);
}
I use the following html code:
<form method="post" action="/EW/forms/form.jsp
<table>
<tr>
<td align="center" colspan="2"><textarea name="comments" rows="6" cols="48"> </textarea></td>
</tr>
</table>
</form>
My javascript:
function form_validator(theForm){
if (theForm.comments.value == ""){
alert("Please provide details.");
theForm.comments.focus();
return (false);
}
return (true);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
but not checks new lines, tabs, special symbols...
and what is very important, it doesn't check the spelling ;)
and what is very important, it doesn't check the spelling ;)
@Gwyn
do you belive that I didn't answer the question?
have you no shame?
do you belive that I didn't answer the question?
have you no shame?
change to:
<textarea name="comments" rows="6" cols="48"></textarea>