Use JS regular control input label only allow input value _javascript tips

Source: Internet
Author: User
Style= "Ime-mode:disabled"
This sentence is more practical. Closes the input method. Saves some people to open the full angle input number, the result input does not go in to seek your kutianmalei, also blames you to design is not good.

Only allow numbers to be entered
Copy Code code as follows:

<input name= "username" type= "text" onkeyup= "Value=this.value.replace (//d+/g, ')" >

Only English letters, numbers, and underscores are allowed (in the following two ways)
Copy Code code as follows:

<input name= "username" type= "text" style= "ime-mode:disabled" >
<input name= "username" type= "text" onkeyup= "Value=value.replace (/[^/w/.//]/ig, ')" >

Only English letters, numbers and &=@ are allowed
Copy Code code as follows:

<input name= "username" type= "text" onkeyup= "Value=value.replace (/[^/w=@&]|_/ig, ')" >

Only allow Chinese characters to be entered
Copy Code code as follows:

<input name= "username" type= "text" onkeyup= "Value=value.replace (/[^/u4e00-/u9fa5]/g, ')" >

Instance: limit input three digits can only be digits or '. ' and close the input method within input
Copy Code code as follows:

<th style= "width:60px;" > Folding    buckle </th>
<span style= "White-space:pre" >
</span><td><input name= " Discountnum "class=" Easyui-validatebox "maxlength=" 3 "style=" ime-mode:disabled "onkeyup=" Value=this.value.replace ( /[^\d.] /g, ' data-options= ' required: ' true ', missingmessage: ' Please fill in the discount number ' '/>
<span style= ' white-space:pre ' >
& Lt;/span></td>

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.