0

How to set input field default value if fieldDisplayName_UserName is null

<td><form:input type="text" path="fieldDisplayName_UserName" id="fieldDisplayName_UserName" onblur="if (this.value == '') 
{this.value = 'User Name';}" 
onfocus="if (this.value == 'User Name') {this.value = '';}" /></td>

I am trying

<td><form:input type="text" path="fieldDisplayName_UserName" 
id="fieldDisplayName_UserName" onblur="if (this.value == '') 
{this.value = 'User Name';}" onfocus="if (this.value == 'User Name') {this.value = '';}" value="User Name"/></td>

but this value always shown

Debojit Saikia
  • 10,532
  • 3
  • 35
  • 46
Ravi Chothe
  • 180
  • 5
  • 17

1 Answers1

1

You could try to set a placeholder like it is suggested in this post

Community
  • 1
  • 1
mvieghofer
  • 2,846
  • 4
  • 22
  • 51