2013-11-26 91 views
0

如何設置輸入字段的默認值,如果fieldDisplayName_UserName是空設置默認值,如果路徑值爲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> 

我想

<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> 

但是這個值總是顯示

回答

1

你可以嘗試設置一個placeholder就像它建議在this post

+0

感謝它的工作正常... :) –