textarea box...

Results 1 to 5 of 5

Thread: textarea box...

  1. #1
    angie Guest

    Default textarea box...

    Is there a way to check that a &#039textarea&#039 box is empty??<BR>How do we do? seems that it works for a normal textbox, but fails for a textarea...yet I can&#039t send a feedback that&#039s empty with nothing in the textarea box...can anyone help pls?

  2. #2
    Join Date
    Dec 1969
    Posts
    34

    Default RE: textarea box...

    why dont u use some javascript in the form page to check if its ok , something like this :<BR>&#060;script language="JavaScript"&#062;<BR><BR>function checkform()<BR>{<BR><BR>if (document.comments.comments.value=="")<BR> {<BR> alert("Please enter your suggestion");<BR> document.comments.comments.focus();<BR> return false;<BR> }<BR>return true;<BR>}<BR>&#060;/script&#062; <BR>&#060;form name="comments" action="SendComments.asp" method="post" onsubmit=" return checkform();"&#062;<BR>........<BR><BR> &#060;tr&#062;<BR> &#060;td valign="top"&#062;Comments&#060;/td&#062;<BR> &#060;td valign="top"&#062;:&#060;/td&#062;<BR> &#060;td&#062;&#060;textarea cols="50" name="comments" rows="12"&#062;&#060;/textarea&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR><BR>.......<BR><BR>then if there is nothing in the textarea the action page wont be run and a blank form will never be sent.<BR>does that help ?

  3. #3
    Paul Mutton Guest

    Default RE: textarea box...

    A better approach is just to ensure that the textarea tags<BR>are placed next to each other with no gap. If you put the<BR>closing tag on the next line, then it will automatically put<BR>an invisible "return" character or two in there.<BR><BR>Incidentally, a clever way to replace all returns with "<BR>"<BR>is to use the following code:<BR><BR>dim str1<BR>str1 = Request.Form("textareabox")<BR>str1 = Replace(Replace(str1, Chr(10), ""), Chr(13), "<BR>")<BR><BR>Cheers,<BR>Paul.

  4. #4
    Paul Mutton Guest

    Default RE: textarea box...

    Ummm, ok, it appears that this message board doesn&#039t like you posting html tags in quotes, cos they&#039ve disappeared!<BR><BR>So for my previous posting, please note that the first occurance of "" should have a &lt;br&gt; in the middle of it and the 3rd and final occurance of "" should also have a &lt;br&gt; in it ;-)<BR><BR>Hopefully someone will fix the code on the message board so that you can post stuff properly... I mean, mine seems to work ok ;-)<BR><BR>paul_merton@hotmail.com


  5. #5
    Vidya Guest

    Default RE: textarea box...

    Hello Angie,<BR>Yes there is a way.<BR>U can check for the number of characters entered in the text area by using document.formname.textarea name.value.length and check to see if it is lesser than 0.This will solve the problem partially. if u have a spacebar being pressed, the length of the texarea is greater than 0 but it is still empty.how will u tackle this?u must write a javascript fn which will scan across all the characters being entered and will prompt the user if an invalid character is entered in the text area.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •