简体   繁体   中英

Set Default value if path value is null

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

你可以尝试设置一个placeholder就像是在暗示这个职位

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM