HTML element input restrictions for various inputs

Source: Internet
Author: User

 1. Cancel the dashed box when the button is pressed, add the attribute value in input hidefocus or Hidefocus=true  <input type= " Submit "value=" Commit "hidefocus=" true "/>2. read-only text box contents, add attribute value in input readonly  < Input type= "text" readonly/>3 <input Type= "text" style= "Behavior:url (#default #savehistory);"/>4 <input type= "text" onkeydown= "if (event.keycode==13) event.keycode=9"/>5 only for Chinese (with flashing)  <input type= "text" onkeyup= "Value=value.replace (/[-~]/g, ')" onkeydown= "if (event.keycode== Event.keycode=9 "/>6. Only numbers (with flashing)  <input type=" text "onkeyup=" value= Value.replace (/[^\d]/g, ') "onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/ [^\d]/g, ')] "/> 

<input type= "Text" min= "1" max= "onkeyup=" Value=value.replace (/[^\d]/g, '); value = value > min? Value:min;value = value > Max? Max:value; "/>

7only for numbers (no flashing)<input type= "text" style= "ime-mode:disabled" onkeydown= "if (event.keycode==13) event.keycode=9" onkeypress= "if (( event.keycode<48 | | event.keycode>57)) Event.returnvalue=false "/>8only English and numerals (with flashing) can be entered.<input type= "text" onkeyup= "Value=value.replace (/[\w]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') "/>9. Shielded Input Method<input type= "text" name= "url" style= "ime-mode:disabled" onkeydown= "if (event.keycode==13) event.keycode=9"/> 10. Enter only numbers, decimal points, minus signs (-) character (no flashing)<input onkeypress= "if (event.keycode!=46 && event.keycode!=45 && (event.keycode<48 | | event.keycode>57)) Event.returnvalue=false "/>11only two decimal places can be entered, three decimal places (with flashing)<input type= "Text" maxlength= "9" onkeyup= "if (Value.match (/^\d{3}$/)) Value=value.replace (Value,parseint (value/ 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} "/> 12only numbers and decimal points can be entered.<input type= "text" size= "onkeyup=" This.value=this.value.replace (/[^\d\.) +?/g, ') '/>13can only enter numbers and English<input onkeyup= "Value=value.replace (/[\w]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">14. You can only enter a number<input onkeyup= "Value=value.replace (/[^\d]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">15. You can only enter full-width<input onkeyup= "Value=value.replace (/[^\uff00-\uffff]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\uff00-\uffff]/g, ') ">16. You can only enter Chinese characters<input onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\u4e00-\u9fa5]/g, ')) ">

HTML element input restrictions for various inputs

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.