user3520443
user3520443

Reputation: 279

Javascript textarea value only appears after focus?

I am having some difficulty with a form field where it is only the textarea field causing the issue that the value appears after I click into the textarea and not already appearing like the input fields:

<textarea name="enquiry" id="enquiry" onfocus="if(this.value == 'Enquiry') this.value='';" onblur="this.value=!this.value?'Enquiry':this.value;" value="Enquiry"></textarea>

Upvotes: 1

Views: 56

Answers (1)

Vinod VT
Vinod VT

Reputation: 7159

Try this,

<textarea name="enquiry" id="enquiry" onfocus="if(this.value == 'Enquiry') this.value='';" onblur="this.value=!this.value?'Enquiry':this.value;">Enquiry</textarea>

Just remove the value attribute and put the text inside <textarea></textarea>

Upvotes: 1

Related Questions