我有一个信用卡号码表单。该号码被分为四部分,就像真正的信用卡一样。
我想在表单中添加JavaScript功能,当用户在一个字段中输入四个字符时,焦点会自动转移到下一个标签,但不会在最后一个标签中发生。通过这样做,用户不必键入“tab”键来移动焦点。
在标签中添加一些额外的类、id或名称都可以。
我想在表单中添加JavaScript功能,当用户在一个字段中输入四个字符时,焦点会自动转移到下一个标签,但不会在最后一个标签中发生。通过这样做,用户不必键入“tab”键来移动焦点。
在标签中添加一些额外的类、id或名称都可以。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>MoveFocus</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
// some code goes here.
});
</script>
</head>
<body>
<form action="post.php" method="post" accept-charset="utf-8">
<input type="text" value="" id="first" size="4" maxlength="4"/> -
<input type="text" value="" id="second" size="4" maxlength="4"/> -
<input type="text" value="" id="third" size="4" maxlength="4"/> -
<input type="text" value="" id="fourth" size="4" maxlength="4"/>
<p><input type="submit" value="Send Credit Card"></p>
</form>
</body>
</html>