Case 1: Enter to achieve Tab jump.
Respond to the onKeyDown event of the text box, get the keyCode clicked by the user.
(*) KeyCode and ASCII are not exactly the same. The main keyboard 1 is the same as the ASCII of the keypad 1, but the keyCode is different. The keyCode for Enter is 13, and the keyCode for Tab is 9.
<body onkeydown="if(==13){=9;}">
Only a few keys can be replaced, most of them cannot do so, and there are permission issues.
The keyboard code is different from the ASCII code.
keyCode
8: Backspace
46:delete
37-40: Direction keys
48-57: Numbers in the keypad area
96-105: Numbers in the main keyboard area
110, 190: The decimal point of the keypad area and the main keyboard area
189, 109: Negative signs of the keypad area and the primary keyboard area
13: Enter
9: Tab is the thing that moves the focus to the next text box.
Case 2: Amount text box
The text boxes involving amounts in financial-related systems have the following requirements:
Enter the amount text box without using Chinese input method
Non-digits cannot be entered
The text box is aligned left when the focus is in the text box; the text box is aligned right when the focus leaves the text box, showing the thousandths
Disable input method: style="ime-mode:disabled" //Compatible with FF and IE, not Chrome
Type illegal values are prohibited, only these can be typed (k == 9) || (k == 13) || (k==46) ||(k==8) ||(k==189) ||(k==109) ||(k==190) ||(k==110) || (k>=48 && k<=57) ||(k>=96 && k<=105) ||(k>=37 && k<=40). onkeydown="return numonKeyDown()" Don't write it as onkeydown="numonKeyDown()" Functions that distinguish between event response functions and event response functions.
Pasting is prohibited (Great Tester), <input onpaste="return false;" , too violent, should just prohibit pasting illegal values. In onpaste, use ('Text') to get the value in the paste board, and then iterate through each character to see if it is a legal value. Paste is only allowed if all are legal values. Paste is prohibited as long as there is an illegal value. charAt, charCodeAt (check character set.doc)
When the focus is in, there are no monsters aligned left, and when the focus is not in, the monsters aligned right. ='right'
The method of adding a thousandth meter, see Notes (*)
====================================
(?=exp) Match the position in front of exp
(?=exp) is also called the zero-width positive prediction predecision assertion, which asserts that the following position of its occurrence can match the expression exp. For example, \b\w+(?=ing\b), matches the previous part of a word ending with ing (parts other than ing), if you look for I'm sing while you're dancing., it matches sing and danc.
===============================
function f(){
var txts=('input');
for(var i=0;i<;i++){
//Carrier Enter to convert to tab
txts[i].onkeydown=function(){
if(==13){
=9;
}
}
txts[i].onpaste=function(){
var usrInput=('Text');
var k;
for(var i=0;i<;i++){
k=(i);
//Only paste . or 0-9 numbers, refer to the ASCII character set.
if((k==46) ||(k>=48 && k<=56)){
}else{
return false;
}
}
}
}
}
Millimeters (exercise code):
function commafy(n)
{
var re=/\d{1,3}(?=(\d{3})+$)/g; //It must end with \d{3}, and must be 1-3 numbers before it, but when replacing, the ending \d{3} numbers are not included. var n1=(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return (re,"$&,")+s2;});
return n1;
}
function addQianFenWei(txtBox)
{
=commafy();
}
function removeQianFenWei(txtBox)
{
=(/,/g,"");//If replace(',','') is to replace only the first one
}
<script type="text/javascript">
function commafy(n)
{
var re=/\d{1,3}(?=(\d{3})+$)/g; //Match 1 to 3 numbers followed by 3 numbers, but does not include the last 3 numbers.
var n1=(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return (re,"$&,")+s2;});
return n1;
}
function setQFW(){
var objTxt=('txtqfw');
var r='';
for(var i=-1;i>=0;i--){
if(i%3==0){
r+=(i)+',';
}else{
r+=(i);
}
}
=r;
//=commafy();
}
</script>
Respond to the onKeyDown event of the text box, get the keyCode clicked by the user.
(*) KeyCode and ASCII are not exactly the same. The main keyboard 1 is the same as the ASCII of the keypad 1, but the keyCode is different. The keyCode for Enter is 13, and the keyCode for Tab is 9.
<body onkeydown="if(==13){=9;}">
Only a few keys can be replaced, most of them cannot do so, and there are permission issues.
The keyboard code is different from the ASCII code.
keyCode
8: Backspace
46:delete
37-40: Direction keys
48-57: Numbers in the keypad area
96-105: Numbers in the main keyboard area
110, 190: The decimal point of the keypad area and the main keyboard area
189, 109: Negative signs of the keypad area and the primary keyboard area
13: Enter
9: Tab is the thing that moves the focus to the next text box.
Case 2: Amount text box
The text boxes involving amounts in financial-related systems have the following requirements:
Enter the amount text box without using Chinese input method
Non-digits cannot be entered
The text box is aligned left when the focus is in the text box; the text box is aligned right when the focus leaves the text box, showing the thousandths
Disable input method: style="ime-mode:disabled" //Compatible with FF and IE, not Chrome
Type illegal values are prohibited, only these can be typed (k == 9) || (k == 13) || (k==46) ||(k==8) ||(k==189) ||(k==109) ||(k==190) ||(k==110) || (k>=48 && k<=57) ||(k>=96 && k<=105) ||(k>=37 && k<=40). onkeydown="return numonKeyDown()" Don't write it as onkeydown="numonKeyDown()" Functions that distinguish between event response functions and event response functions.
Pasting is prohibited (Great Tester), <input onpaste="return false;" , too violent, should just prohibit pasting illegal values. In onpaste, use ('Text') to get the value in the paste board, and then iterate through each character to see if it is a legal value. Paste is only allowed if all are legal values. Paste is prohibited as long as there is an illegal value. charAt, charCodeAt (check character set.doc)
When the focus is in, there are no monsters aligned left, and when the focus is not in, the monsters aligned right. ='right'
The method of adding a thousandth meter, see Notes (*)
====================================
(?=exp) Match the position in front of exp
(?=exp) is also called the zero-width positive prediction predecision assertion, which asserts that the following position of its occurrence can match the expression exp. For example, \b\w+(?=ing\b), matches the previous part of a word ending with ing (parts other than ing), if you look for I'm sing while you're dancing., it matches sing and danc.
===============================
Copy the codeThe code is as follows:
function f(){
var txts=('input');
for(var i=0;i<;i++){
//Carrier Enter to convert to tab
txts[i].onkeydown=function(){
if(==13){
=9;
}
}
txts[i].onpaste=function(){
var usrInput=('Text');
var k;
for(var i=0;i<;i++){
k=(i);
//Only paste . or 0-9 numbers, refer to the ASCII character set.
if((k==46) ||(k>=48 && k<=56)){
}else{
return false;
}
}
}
}
}
Millimeters (exercise code):
Copy the codeThe code is as follows:
function commafy(n)
{
var re=/\d{1,3}(?=(\d{3})+$)/g; //It must end with \d{3}, and must be 1-3 numbers before it, but when replacing, the ending \d{3} numbers are not included. var n1=(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return (re,"$&,")+s2;});
return n1;
}
function addQianFenWei(txtBox)
{
=commafy();
}
function removeQianFenWei(txtBox)
{
=(/,/g,"");//If replace(',','') is to replace only the first one
}
Copy the codeThe code is as follows:
<script type="text/javascript">
function commafy(n)
{
var re=/\d{1,3}(?=(\d{3})+$)/g; //Match 1 to 3 numbers followed by 3 numbers, but does not include the last 3 numbers.
var n1=(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return (re,"$&,")+s2;});
return n1;
}
function setQFW(){
var objTxt=('txtqfw');
var r='';
for(var i=-1;i>=0;i--){
if(i%3==0){
r+=(i)+',';
}else{
r+=(i);
}
}
=r;
//=commafy();
}
</script>