English 中文(简体)
我如何把 cur子从第一个文本的字塔移至第二个文本区域,而不使用表格或 mo?
原标题:How do I move the cursor from the first textarea to a second textarea, without using tab or the mouse?

I m building a password box that holds three text areas. Each text area has one character. After I type the first character of the password, I have to press tab or use the mouse to get to the second text area to type the second character of the password. I would like to make this happen automatically (cursor movement) just right after I type in the first text area.

我如何能够做到这一点?

If you may ask, I m using Visual Studio .NET 2008 in C# I m a perfect newbie in .net and I don t know how to ask this question with the appropiate words.

谢谢。

问题回答

Try onKeyPress。 这应当照顾你们所期待的东西。

<input type="text" name="password" onKeyPress="autoTab()" />

<script type="text/javascript" language="JavaScript">
   function autoTab() {
     //do stuff
   }
</script>

这里的理论涉及改变一个领域的治疗地位。

http://www.webdeveloper.com/forum/showthread.php?t=91817

这表明,你的自治职能应当如此。

function autoTab(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

你们是否在项目中使用 j子?

<!DOCTYPE html>
<html>
<head>
<title>example</title>
<style type="text/css">
    *
    {
        margin: 0;
        padding: 0;
    }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

    $(function () {

        $( #data1 ).keyup(function () {

            if ($(this).val().length == 1) {

                $( #data2 ).focus();
            }

        });

    });

</script>
</head>
<body>
<input id="data1" type="text" value="" style="width: 10px" /><br />
<input id="data2" type="text" value="" style="width: 10px" />
</body>
</html>
if textbox1.text.length > 0 then textbox2.focus();




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签