Asp.net mvc 4 如何在Html.TextBoxFor(或Html.TextBox)中自动标记(光标)?
我是ASP.NETMVC4的新手,有什么问题吗 我有5个文本框下面的图片(链接) 在每个文本框中,我为其设置maxlength。以下图片(链接) 当我向每个文本框插入数据时,我想自动制表Asp.net mvc 4 如何在Html.TextBoxFor(或Html.TextBox)中自动标记(光标)?,asp.net-mvc-4,html.textboxfor,Asp.net Mvc 4,Html.textboxfor,我是ASP.NETMVC4的新手,有什么问题吗 我有5个文本框下面的图片(链接) 在每个文本框中,我为其设置maxlength。以下图片(链接) 当我向每个文本框插入数据时,我想自动制表 Example : when I insert "1" to textbox1(maxlength=1) cursor will go to textbox2 AUTO 此后,我想将数据设置为所有文本框 示例:字符串值=textbox1+textbox2+…+文本框5 value = 12
Example : when I insert "1" to textbox1(maxlength=1) cursor will go to textbox2 AUTO
此后,我想将数据设置为所有文本框
示例:字符串值=textbox1+textbox2+…+文本框5
value = 1222233333...
对于可能发生的任何错误,请提前接受我诚挚的道歉
非常感谢。像下面这样的方法应该可以奏效 加价
<div class="tax">
<input type="text" maxlength="1" />
<input type="text" maxlength="4" />
<input type="text" maxlength="5" />
<input type="text" maxlength="2" />
<input type="text" maxlength="1" />
</div>
小提琴:
希望这有帮助。谢谢您的回答。所以我是MVC和Javascript新手。我不知道如何声明Javascript(您的代码:$(函数(){)如何声明它。(在视图、控制器等中)请检查mvc应用程序中的js管理谢谢!现在我可以解决这个问题了。谢谢您的帮助。
<div class="tax">
<input type="text" maxlength="1" />
<input type="text" maxlength="4" />
<input type="text" maxlength="5" />
<input type="text" maxlength="2" />
<input type="text" maxlength="1" />
</div>
$(function () {
$('.tax input[type="text"]').keypress(function (e) {
if (e.which == 0 || e.charCode == 0) {
return true;
}
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
str = $(this).val() + str;
if (str.length == $(this).prop('maxlength')) {
var that = this;
window.setTimeout(function(){
$(that).next('input[type="text"]').focus();
}, 0);
}
});
});