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;
}
}
}