Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

help, text area on forms

Status
Not open for further replies.
Joined
Jun 1, 2010
Posts
548
Reaction score
2
I'm using the following to set up the input fields in my form:

<input class="form2" onfocus="this.select()" onblur="this.value=!this.value?'Mobile':this.value;" onclick="this.value='';"/ type="text" name="mobile" size="24" style="color:#888;"
value="Mobile" />

This displays what to enter in the field (eg. name, mobile), which then disappears on click and comes back if nothing is entered and the user clicks outside of the box. The 'value=""' attribute is needed otherwise no text appears in the input fields from page load, only once a user has clicked in and out of the field.

I have a text area at the bottom of my form which I want to behave in the same manner. I can get it to display the default text I want when the user has clicked in and out of the box, but not from page load. I've added the value attribute but it doesn't make any difference..

Can anyone help? The code I'm using for the text area is as follows:

<textarea class="form2" onfocus="this.select()" onblur="this.value=!this.value?'Description (50 words max)':this.value;" onclick="this.value='';"/ rows="9" style="color:#888" name="message" cols="30" value="Description (50 words max)"></textarea>
 
Its because textarea works differently - The contents are originally declared by whats inbetween <textarea> and </textarea>

Code:
<textarea class="form2" onfocus="this.select()" onblur="this.value='Description (50 words max)'" onclick="this.value=''"/ rows="9"  cols="30" value="">Description (50 words max)</textarea>

However this isn't a very efficient way of clearing a form to be honest, what you should do is check if they have entered anything within the form and not clear it if they have:

Code:
<textarea class="form2" onfocus="this.value=''" onblur="if(this.value=='')this.value='Description (50 words max)';" rows="9"  cols="30" value="">Description (50 words max)</textarea>

I also moved the value clearing to onfocus - If a user uses there keyboard to navigate to the field (pressing tab) then it will now clear.
 
Last edited:
Status
Not open for further replies.

Rule #1: Be Respectful

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Siusaidh AcornBot:
    Siusaidh has left the room.
      Siusaidh AcornBot: Siusaidh has left the room.
      Top Bottom