Js limits input to Numbers letters characters and so on
- 2020-03-30 00:56:58
- OfStack
<input type="text"onKeyUp="this.value=this.value.replace(/[^.d]/g,'');if(this.value.split('.').length>2){this.value=this.value.split('.')[0]+'.'+this.value.split('.')[1]}">
1. Text box can only enter numeric code (decimal point can not enter)
<input not nkeyup="this.value=this.value.replace(/D/g,'''')" not nafterpaste="this.value=this.value.replace(/D/g,'''')">
2. Can only input Numbers, can input decimal points.
<input not nkeyup="if(isNaN(value))execCommand(''undo'')" not nafterpaste="if(isNaN(value))execCommand(''undo'')">
<input name=txt1 not nchange="if(/D/.test(this.value)){alert('' You can only enter Numbers '');this.value='''';}">
3. Number and decimal point method two
<input type=text t_value="" o_value="" not nkeypress="if(!this.value.match(/^[+-]?d*?.?d*?$/))this.value=this.t_value;elsethis.t_value=this.value;if(this.value.match(/^(?:[+-]?d+(?:.d+)?)?$/))this.o_value=this.value" not nkeyup="if(!this.value.match(/^[+-]?d*?.?d*?$/))this.value=this.t_value;elsethis.t_value=this.value;if(this.value.match(/^(?:[+-]?d+(?:.d+)?)?$/))this.o_value=this.value" not nblur="if(!this.value.match(/^(?:[+-]?d+(?:.d+)?|.d*?)?$/))this.value=this.o_value;else{if(this.value.match(/^.d+$/))this.value=0+this.value;if(this.value.match(/^.$/))this.value=0;this.o_value=this.value}">
4. Only input letters and Chinese characters
<input not nkeyup="value=value.replace(/[d]/g,'''')"onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[d]/g,''''))"maxlength=10 name="Numbers">
5. Input English letters and Numbers only, not Chinese
<input not nkeyup="value=value.replace(/[^w./]/ig,'''')">
6. Enter Numbers and English only
<input not nKeyUp="value=value.replace(/[^d|chun]/g,'''')">
7. No more than two digits can be entered after the decimal point. No more letters or operational symbols can be entered:
<input not nKeyPress="if((event.keyCode<48 ||event.keyCode>57) &&event.keyCode!=46 ||/.dd$/.test(value))event.returnValue=false">
8. There can be no more than two digits after the decimal point (digits, letters and Chinese characters can be input). Operation symbols can be input:
<input not nkeyup="this.value=this.value.replace(/^(-)*(d+).(dd).*$/,''$1$2.$3'')">