Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Leaving textbox control
Message
From
31/07/2003 13:54:35
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00813238
Message ID:
00815528
Views:
10
::Is it possible make asp.net form work somewhat like a VFP form where once user enters the text in a textbox (specified in Columns property) the focus goes to the next textbox? That is, without user having to mouse click or tab out of the textbox.

I am assuming your are referring to an example where you have three input boxes for a social security number and when they enter the last digit in each input box you want the focus to automatically jump to the next box?

If this is the case then you can use JavaScript to do this. An example follows:
<script language="JavaScript">
  function oFocus(){
    if(len(this.myform.s1.value) == 3)
      {
         this.myform.s2.focus();
      }
  }

  function oFocus1(){
    if(len(this.myform.s2.value) == 2)
      {
         this.myform.s3.focus();
      }
  }
</script>


<body>
  <form id="myform">
     <asp:input onchange="javascript:cFocus()" type="textbox" id="s1" maxlength=3 />
     <asp:input onchange="javascript:cFocus1()" type="textbox" id="s2" maxlength=2 />
     <asp:input type="textbox" id="s3" maxlength=4 />

  </form>
</body>
You can optimize the script some more but you get the general idea. I hope my syntax is correct!

HTH

WEs
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform