• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

Cursor in Text field

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
0
thomas908
Asked:
thomas908
  • 3
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
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
0
 
thomas908Author Commented:
It's IE on windows.
0
 
thomas908Author 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.
0
 
Michel PlungjanIT ExpertCommented:
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"

0
 
thomas908Author Commented:
Thanks a lot. That works perfect
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now