The implementation code of pre-input content is represented by asterisks in javascript.

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.