• Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

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.
Top Bottom