tags:

views:

168

answers:

2

A form on my website's contact -us HTML page has two fields

1) subject

2) message

When the page loads for the first time I want these two boxes to display messages like "Enter subject here" and "Enter Message here".

I found that we can do this by using the "value" attribute of the text box, is this the best way ??.. What alternatives do I have to achieve this ?

+2  A: 

Yes, that is the best way. You can then use JavaScript to empty the text input/area when the element gains focus. Remember to consider how you want to handle the case where the user submits the default text. I.e, is "Enter username" a valid username or not?

PatrikAkerstrand
+3  A: 
David Dorward
+1. Innovative, clean and accessible solution! Requires a bit more effort from the developer though (that's not really a criticism, merely an observation)
PatrikAkerstrand
I've just remembered, there is an example of this in action (my first implementation of this I think) at http://playfire.com/ (the big login form near the middle/right of the page)
David Dorward
Thanks guys.I'll go with David's.This way I save the necessity to validate inout to chek if user has submitted default value (as mentione by Machine ). thanks all of you
Annibigi