JavaScript text box input four digit automatic space script _ form effect

Source: Internet
Author: User
Enter more than one character, you will find four digits automatically add space
<textarea id="runcode61210"><ptml> <script language=javascript> function test () {var Len=document.getelementbyid (' card '). Value.length; var reg =/\s{1,}/g; var card_ = ""; var Card=document.getelementbyid (' card '). Value; Remove Space card = Card.replace (Reg, ""); for (var i = 0;i < len;i++) {if (i = = 3| | i = = 7 | | i = = 11| | (i = =) {Card_ = Card_ + Card.charat (i) + ""; else {Card_ = Card_ + Card.charat (i); } document.getElementById ("card"). Value = Card_; } </script> <body> <input type= "text" id= "card" onkeyup= "Test ()" > </body> &L T;/html></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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: 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.