65.9K
CodeProject is changing. Read more.
Home

onfocus , onblur :: input box / textbox

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.67/5 (2 votes)

Dec 19, 2009

CPOL
viewsIcon

13403

for asp.net<asp:TextBox ID="txtUserName" Text ='Enter User Name' onFocus="if (this.value == 'Enter User Name' || this.value == 'User Name Not found' || this.value == 'Password Not found' || ...

for asp.net
<asp:TextBox ID="txtUserName" 
             Text ='Enter User Name'  
             onFocus="if (this.value == 'Enter User Name'     || 
                          this.value == 'User Name Not found' || 
                          this.value == 'Password Not found'  || 
                          this.value == 'User Name and Password Mismatch')
                      {
                          this.value           = '';
                          this.style.color     = 'Black';
                          this.style.fontStyle = 'normal';
                      }" 
             onBlur="if (this.value == '') 
                     {
                         this.style.color     = 'gray';
                         this.value           = 'Enter User Name';
                         this.style.fontStyle = 'italic';
                     }" 
             AutoCompleteType="Disabled"  
             class="flatboxlogin" 
             runat="server" 
             BackColor="Transparent" 
             BorderColor="Transparent" 
             Font-Italic ="true"  
             ForeColor="gray">

EDIT =========== Made your code snippet more readable.