Advertisement
2_2002-2004 Controls/ Forms/ Graphics/ Menus #126326

Text Box Jump

This script will allow you to jump from one text box to the next when a desired length is reached.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
<script LANGUAGE="JavaScript">
<!-- Begin
// Author: Michael Ray Brown
// Email: mrb23@bellsouth.net
//
// This script will allow you to jump from one text box to the next
// when a desired length is reached. There are two input variables
// ObjName --> Name of Text Box
// ObjNum --> Max characters to be typed before jumping
// 
// to call this function place the following code to your text box
// instantiaion --> onkeyup="NextBox('text_box_name',value to jump at(int));"

function NextBox(ObjName,ObjNum) {
// 1st example
if (ObjName == "textbox_name here") {
	// move to next text field
	if (ObjNum == 2) {
		if (document.form_name.textbox_name1.value.length == "set value you want to jump at(example='3')) {
			document.form_name.textbox_name2.focus()
			}
		else {
			document.form_name.textbox_name1.focus()
			}
		}
	}
// 2nd example
else if (ObjName == "textbox_name here") {
	// move to next text field
	if (ObjNum == 2) {
		if (document.form_name.textbox_name1.value.length == 2) {
			document.form_name.textbox_name2.focus()
			}
		else {
			document.form_name.textbox_name1.focus()
			}
		}
	}
// 3rd example featuring 4 text boxes
// a good example would be for credit card # input
else if (ObjName == "textbox_name here") {
	// move to next text field
	if (ObjNum == 2) {
		if (document.form_name.textbox_name1.value.length == 4) {
			document.form_name.textbox_name2.focus()
			}
		else {
			document.form_name.textbox_name1.focus()
			}
		}
	else if (ObjNum == 3) {
		if (document.form_name.textbox_name2.value.length == 4) {
			document.form_name.textbox_name3.focus()
			}
		else {
			document.form_name.textbox_name2.focus()
			}
		}
	else if (ObjNum == 4) {
		if (document.form_name.textbox_name3.value.length == 4) {
			document.form_name.textbox_name4.focus()
			}
		else {
			document.form_name.textbox_name3.focus()
			}
		}
	}
}
// End -->
</script>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine