We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Cursor in Text field

thomas908
thomas908 asked
on
Medium Priority
489 Views
Last Modified: 2012-05-05
I have some form fields like
       <!-- FirstName Field  //-->        
     <div class="formfield_row">
         <div class="formfield_label"> <%= firstNameLabel %> <span class="required">*</span></div>
         <div class = "formfield_input">
           &nbsp;<input  class="formfield"
                           type="text"
                           name="usr_firstname"
                           value="<%= firstName%>"
                                   onfocus="if(this.value=='<%= usrFirstNameDefault %>')this.value = ''"
                                  onblur="if(this.value=='')this.value='<%= usrFirstNameDefault %>';"
                           maxLength="30"/>
          </div>
      </div>

      <!-- LastName Field  //-->
    <div class = "formfield_row">
        <div class = "formfield_label"><%= lastNameLabel %> <span class="required">*</span></div>
        <div class = "formfield_input">
               &nbsp;<input class="formfield"
                                       type = "text"
                                 name = "usr_lastname"
                                 value = "<%= lastName%>"
                                 onfocus="if(this.value=='<%= usrLastNameDefault %>')this.value = ''"
                                   onblur="if(this.value=='')this.value='<%= usrLastNameDefault %>';"
                                 maxLength = "30"/>
          </div>
     </div>
   
      <!-- CompanyName Field   //-->    
    <div class = "formfield_row">
            <div class = "formfield_label"><%= compNameLabel %></div>
            <div class = "formfield_input">
            &nbsp;<input class="formfield"
                                 type = "text"
                           name = "usr_comp_name"
                           value = "<%= compName%>"
                           onfocus="if(this.value=='<%= usrCompNameDefault %>')this.value = ''"
                                   onblur="if(this.value=='')this.value='<%= usrCompNameDefault %>';"
                              maxLength = "30"/>
            </div>
      </div>
     

The problem is that when the user navigates from one field to another using "Tab", a blinking cursor is not placed in that field. Is there any way to enforce it?
When the user clicks on the field using a mouse then its working fine.
Thanks
Comment
Watch Question

Michel PlungjanIT Expert
CERTIFIED EXPERT
Top Expert 2009

Commented:
In what browser on what platform?

If I tab in IE win, there is a big blue highlight - not a blinking cursor. That is normal behaviour and something I as a user REALLY prefer
If you want the blinking cursor, you need an empty field

Author

Commented:
It's IE on windows.

Author

Commented:
The contents in the field get erased as soon as the focus comes on that field. But the problem is that the curson is not displayed. There is no big blue highlight in this case. Also If I click on the field using mouse the cursor appears. I want it to appear when tab navigating.
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
You do not get the cursor when you set the value.

Here is the solution:

onfocus="if(this.value==defaultValue) this.value = ''; this.select()"
onblur="if(this.value=='') this.value=this.defaultValue"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks a lot. That works perfect
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.