Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow making text appear in text-area before input

    Hey,

    I've seen this before, and it might be simple, but I have no idea what to do. I want to make the text area (where you type for a forum reply like I am doing right now) have a line of text warning people to read the rules before they post. I want this sentence to vanish when they click within the text area to type.

    Any idea how? here's the code:

    Code:
        <td class="pformright" valign='top'><textarea cols='70' rows='15' name='Post' tabindex='3' class='textinput'>$data</textarea></td>
    Thanks.

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wouldn't:
    Code:
    <textarea cols='70' rows='15' name='Post' tabindex='3' class='textinput'>Please read the rules before posting!</textarea>
    Do it, if that's what you're talking about, just like i have a little bit of text in my contact textarea:
    http://www.dotfive.com/contact.php
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    In order to make that text vanish, you'd need some javascript running, probably onfocus, that would compare the value of the textarea to your default text, if it is the same then clear the text. I've used this on standard text inputs before, I'm sure it would work on textarea too.
    Code:
    onfocus="if(this.value=='Please read the rules before posting!') this.value=''"
    What might be nicer though (no js required) would be big bold red text just above the textarea or above the submit button that says that same thing. Doing this you can make use of color and font changes to attract attention to the important text.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Another thing that might be fun would be to have a secondary text entry (just input, not textarea) that requires a certain word from the rules page. The visitor has to at least look at the rules to find the required word before the post is accepted. With a bit of server-side work you could even make this semi-random so someone can't get away with just using the same word.

    If this is for a forum, you might just require this "Rules Read" verification while the person has posted fewer than 10 messages. This way veteran users don't get upset at having to hunt through the rules every time they want to say something.

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Good one kansel
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #6
    Regular Coder
    Join Date
    Oct 2002
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow

    Hmm.. in this code:

    Code:
         </td>
         <td class="pformright" valign='top' ><textarea cols='70' rows='15' name='Post' tabindex='3' class='textinput'>$data</textarea></td>
       </tr>
    onfocus="if(this.value=='Please read the etiquette (click the link to it above) before posting!') this.value=''"

    doesn't seem to work I put it nearly everywhere in that text to see if it was just me.

    Any ideas?


    P.S. Kasal..that is a great idea, but they might get confused..but I might do it anyway..what a great idea!

  • #7
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd advise against such things as forcing them to read the rules... Most people don't need to, as they are typically equipped with common sense. The best way to do it would be to state that "by submitting this form you agree to the <a>forum rules</a>" and link them to the rules. If they choose not to read them, you can choose to take whatever action is necessary.

    As for the other thing: His script assumes you've given the textarea a default value of 'Please read the rules before posting!'. You haven't. Your textarea's initial value is '$data', or whatever that PHP variable equals. Replace that with 'Please read the rules before posting!' (sans quotes) and it'll work.

  • #8
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're going to do your form validation and error checking clientside, I'd recommend something along the following lines:


    PHP Code:
    <script type="text/javascript">
    <!--

    function 
    chkFrm(){

    var 
    doc document['formName'];
    if (
    doc['tos'].checked){
    doc.submit();
    }else{
    alert("Form Error:  You must agree to the\n Terms Of Service before posting!");
    return 
    false;
    }
    }

    //-->
    </script>

    <form name="formName">
    <input name="tos" type="checkbox" />
    <textarea cols="70" rows="15" name="Post" tabindex="3" class="textinput">$data</textarea>
    <input name="oBtn" type="button" value="Submit" onclick="javascript:chkFrm();" />
    </form> 

    -james
    Last edited by jamescover; 09-25-2004 at 02:34 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

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