Only numbers, decimal places, English letters, and Chinese characters can be entered in the restricted text box.

Source: Internet
Author: User
1. the text box can only enter the number code (decimal point cannot be entered): inputonkeyupthis. valuethis. value. replace (Dg,) onafterpastethis. valuethis. value. replace (Dg,) 2. only numbers are allowed, and decimal points are allowed. (method 1) inputonkeyupif (isNaN (value) execCommand (undo

1. the text box can only enter the number code (decimal point cannot be entered): input onkeyup = "this. value = this. value. replace (// D/g, '')" onafterpaste = "this. value = this. value. replace (// D/g, '')" 2. only numbers are allowed, and decimal points are allowed. (method 1) input onkeyup = "if (isNaN (value) execCommand ('undo'

1. Only numeric code can be entered in the text box (or decimal point ):

2. You can enter only numbers and decimal places. (method 1)

3. Number and decimal point method 2

4. Only letters and Chinese characters can be entered

5. Only English letters and numbers are allowed. Chinese characters are not allowed.

6. Only numbers and English letters can be entered.

7. After the decimal point, you can enter a maximum of two digits (numbers and Chinese characters). You cannot enter letters or operator numbers:

8. A maximum of two digits (numbers, letters, and Chinese characters) can be entered after the decimal point. You can enter the operator number:

The onkeypress event is called to limit that only numbers and decimal places can be entered in the text box (and only once)

Function KeyPress (objTR)

{

Var txtval = objTR. value;

Var key = event. keyCode;

If (key <48 | key> 57) & key! = 46)

{

Event. keyCode = 0;

}

Else

{

If (key = 46)

{

If (txtval. indexOf (".")! =-1 | txtval. length = 0)

Event. keyCode = 0;

}

}

}

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.