Recommend a good form input advanced Usage 11 Cases _ Experience Exchange

Source: Internet
Author: User
1. The dashed box when the Cancel button is pressed
Add attribute value in input hidefocus or hidefocus=true

2. Read-only text box contents
Add attribute value in input readonly

3. Prevent back-emptying of the text document (you can make the style content as a class reference)
<input Style=behavior:url (#default #savehistory); Type=text id=opersistinput>

The 4.ENTER key allows the cursor to move to the next input box
<input onkeydown= "if (event.keycode==13) event.keycode=9" >

5. Only for Chinese (with flashing)
<input onkeyup= "Value=value.replace (/[-~]/g, '") "onkeydown=" if (event.keycode==13) event.keycode=9 ">

6. Only for numbers (with flashing)
<input onkeyup= "Value=value.replace (/[^\d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">

7. Only for numbers (no flashing)
<input style= "ime-mode:disabled" onkeydown= "if (event.keycode==13) event.keycode=9" onkeypress= "if ( event.keycode<48 | | event.keycode>57)) Event.returnvalue=false ">

8. Can only input English and digital (with flashing)
<input onkeyup= "Value=value.replace (/[\w]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') ">

9. Shielding Input Method
<input type= "text" name= "url" style= "ime-mode:disabled" onkeydown= "if (event.keycode==13) event.keycode=9" >

10. Only digits, decimal points, minus (-) characters (no flashing) can be entered.
<input onkeypress= "If" (event.keycode!=46 && event.keycode!=45 && (event.keycode<48 | | event.keycode>57)) Event.returnvalue=false ">

11. Can only enter two decimal places, three decimal places (with flashing)
  <input 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} " id=text_kfxe name=text_kfxe> 

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.