JS Limit input Input

Source: Internet
Author: User

1. Cancel the dashed box when the button is pressed, add the attribute value in input hidefocus or hidefocus=true<inputtype= "Submit"value= "Submit"Hidefocus= "true" />2. Read-only text box contents, add attribute value in input readonly<inputtype= "text"ReadOnly/>3. Prevent the text document from being emptied (you can use the style content as a class reference)<inputtype= "text"style= "Behavior:url (#default #savehistory);" />4.ENTER Key to move the cursor to the next input box<inputtype= "text"onkeydown= "if (event.keycode==13) event.keycode=9" />5. Only Chinese (with flashing)<inputtype= "text"onkeyup= "Value=value.replace (/[-~]/g, ')"onkeydown= "if (event.keycode==13) event.keycode=9" />6. Only digital (with flashing)<inputtype= "text"onkeyup= "Value=value.replace (/[^\d]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\d]/g, ")" />7. Only digital (no flashing)<inputtype= "text"style= "ime-mode:disabled"onkeydown= "if (event.keycode==13) event.keycode=9"onkeypress= "if ((event.keycode<48 | | event.keycode>57)) event.returnvalue=false" />8. Only input English and numerals (with flashing)<inputtype= "text"onkeyup= "Value=value.replace (/[\w]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\d]/g, ")" />9. Shielding Input Method<inputtype= "text"name= "url"style= "ime-mode:disabled"onkeydown= "if (event.keycode==13) event.keycode=9" />10. Enter only digits, decimal point, minus (-) character (no flashing)<inputonkeypress= "If" (event.keycode!=46 && event.keycode!=45 && (event.keycode<48 | | event.keycode>57)) Event.returnvalue=false " />11. Only two decimal places can be entered, three decimal places (with flashing)<inputtype= "text"maxlength= "9"onkeyup= "if (Value.match (/^\d{3}$/)) Value=value.replace (Value,parseint (VALUE/10)); Value=value.replace (/\.\d*\./g, ' . ') 'onkeypress= "if ((event.keycode<48 | | event.keycode>57) && event.keycode!=46 && event.keycode!=45 | | Value.match (/^\d{3}$/) | | /\.\d{3}$/.test (value)) {Event.returnvalue=false} " />12. Only numbers and decimal points can be entered<inputtype= "text"size= " a"onkeyup= "This.value=this.value.replace (/[^\d\.) +?/g, ")" />13. You can only enter numbers and English<inputonkeyup= "Value=value.replace (/[\w]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\d]/g, ")">14. You can only enter a number<inputonkeyup= "Value=value.replace (/[^\d]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\d]/g, ")">15. Only full-width input<inputonkeyup= "Value=value.replace (/[^\uff00-\uffff]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\uff00-\uffff]/g, ")">16. Only input characters<inputonkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')"Onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text ')." Replace (/[^\u4e00-\u9fa5]/g, ")">

JS Limit input Input

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.