Copy the code code as follows:
<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. Only numeric codes can be entered in the text box (decimal points cannot be entered either)
Copy the code code as follows:
<inputōnkeyup="this.value=this.value.replace(//D/g,'''')"ōnafterpaste="this.value=this.value.replace(//D/g,'''') ">
2. Only numbers can be entered, decimal points can be entered.
Copy the code code as follows:
<inputōnkeyup="if(isNaN(value))execCommand(''undo'')"ōnafterpaste="if(isNaN(value))execCommand(''undo'')">
<input name=txt1ōnchange="if(//D/.test(this.value)){alert(''Only numbers can be entered'');this.value='''';}">
3. Numbers and decimal point method 2
Copy the code code as follows:
<input type=text t_value="" o_value=""ō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"ōnkeyup="if(!this.value.match(/^[/+/-]?/ d*?/.?/d*?$/))this.value=this.t_value;elsethis.t_value=this.va lue;if(this.value.match(/^(?:[/+/-]?/d+(?:/./d+)?)?$/))this.o_value=this.value"ōnblur=" if(!this.value.match(/^(?:[/+/-]?/d+(?:/./d+)?|/./d*?)?$/))th is.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 letters and Chinese characters can be entered
Copy the code code as follows:
<input ōnkeyup="value=value.replace(/[/d]/g,'''')"onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace (/[/d]/g,''''))"maxlength=10 name="Numbers">
5. Only English letters and numbers can be entered, but Chinese characters cannot be entered.
Copy the code code as follows:
<inputōnkeyup="value=value.replace(/[^/w/.//]/ig,'''')">
6. Only numbers and English can be entered
Copy the code code as follows:
<inputōnKeyUp="value=value.replace(/[^/d|chun]/g,'''')">
7. There can only be a maximum of two digits after the decimal point (both numbers and Chinese characters can be entered). Letters and arithmetic symbols cannot be entered:
Copy the code code as follows:
<inputōnKeyPress="if((event.keyCode<48 ||event.keyCode>57) &&event.keyCode!=46 ||//./d/d$/.test(value))event.returnValue=false">
8. There can only be up to two digits after the decimal point (numbers, letters, and Chinese characters can be entered), and arithmetic symbols can be entered:
Copy the code code as follows:
<inputōnkeyup="this.value=this.value.replace(/^(/-)*(/d+)/.(/d/d).*$/,''$1$2.$3'')">