For example, if it is 14 characters, 14 characters can be entered before the user input). When the user starts to input data, * is replaced in sequence, enter a few characters and replace them with a few characters. After the input, only the information entered by the user is displayed in the text box. I am still suffering from such a function for a while. Ah, the JS level is still too good, so I posted a post for help. Later, with the help of huangwenquan123, A CSDN user, I have fixed this problem. Now I am posting the Code directly, hoping to help my friends who need it:
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "http://demo.jb51.net/JSlib/jquery/jquery-1.3.2.min.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# TxtCustomsCode"). keydown (function (e) {// process the keydown event for the text box to be processed
E = e | window. event;
Var code = e. keyCode | e. which;
If (code> = 96 & code <= 105) | (code> = 65 & code <= 90) | (code> = 48 & code <= 57) {// you can enter uppercase/lowercase letters and numbers (including keypad)
Var userkeydown = $ (this). val (). substr (14 );
Var reg = /\*/;
$ (This). val ($ (this). val (). replace (reg, userkeydown ));
$ (This). val ($ (this). val (). substr (0, 14 ))
}
Else
$ (This). val ($ (this). val (). substr (0, 14 ))
})
})
</Script>