The ENTER key moves the cursor to the next input box
<input onkeydown="if(event.keyCode==13)event.keyCode=9" >
Can only be in Chinese
<input onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9">
Block input method
<input style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9">
Only English and numbers can be entered
<input onkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d ]/g,''))" onkeydown="if(event.keyCode==13)event.keyCode=9">
can only be numbers
<input onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/ d]/g,''))">
Can only be displayed, not modified
<input readonly value="Can only be displayed, not modified">
Only numbers can be entered to determine the value of the keys
Copy the code code as follows:
<script language=javascript>
function onlyNum()
{
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)||(event.keyCode==8)))
event.returnValue=false;
}
</script>
<input onkeydown="onlyNum();">
1. Only numeric codes can be entered in the text box (decimal points cannot be entered either)
<input onkeyup="this.value=this.value.replace(//D/g,'')" onafterpaste="this.value=this.value.replace(//D/g,'')">
2. Only numbers can be entered, decimal points can be entered.
<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
<input name=txt1 onchange="if(//D/.test(this.value)){alert('Only numbers can be entered');this.value='';}">
3. Numbers and decimal point method 2
<input type=text t_value="" o_value="" onkeypress="if(!this.value.match(/^[/+/-]?/d*?/.?/d*?$/))this .value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[/+/-]?/d+(?:/./d+)?)?$/))this.o_value=this .value" onkeyup="if(!this.value.match(/^[/+/-]?/d*?/.?/d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[/+/-]?/d+(?:/./d+)?)?$/))this.o_value=this .value" onblur="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 letters and Chinese characters can be entered
<input onkeyup="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.
<input onkeyup="value=value.replace(/[^/w/.//]/ig,'')">
6. Only numbers and English<font color="Red">chun</font> can be entered
<input onKeyUp="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:
<input onKeyPress="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:
<input onkeyup="this.value=this.value.replace(/^(/-)*(/d+)/.(/d/d).*$/,'$1$2.$3')">
It can only be numbers and decimal points and addition, subtraction and multiplication
9. Only numbers, decimal points, and negative numbers can be entered.
Copy the code code as follows:
<input name="input" type="text" onkeyup="JHshNumberText(this)" id="title">
<script language="javascript" type="text/javascript">
function JHshNumberText(a)
{
var fa="";
if(a.value.substring(0,1)=="-")
fa="-";
var str=(a.value.replace(/[^0-9.]/g,'')).replace(/[.][0-9]*[.]/, '.');
if (str.substring(0,1)==".")
str="0"+str;
a.value=fa+str;
}
</script>
1. Cancel the dotted frame when the button is pressed, and add the attribute value hideFocus or HideFocus=true to the input.
<input type="submit" value="Submit" hidefocus="true" />
2. To read only the content of the text box, add the attribute value readonly in the input
<input type="text" readonly />
3. Prevent TEXT documents that are cleared after going back (the style content can be used as a class reference)
<input type="text" style="behavior:url(#default#savehistory);" />
4. The ENTER key can move the cursor to the next input box.
<input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" />
5. Can only be in Chinese (with flashing)
<input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" />
6. Can only be numbers (with flashing)
<input type="text" onkeyup="value=value.replace(/[^/d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace (/[^/d]/g,''))" />
7. Can only be numbers (no flashing)
<input type="text" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" onkeypress="if ((event.keyCode<48 || event.keyCode >57)) event.returnValue=false" />
8. Only English and numbers can be entered (with flashing)
<input type="text" onkeyup="value=value.replace(/[/W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace( /[^/d]/g,''))" />
9. Shield input method
<input type="text" name="url" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" />
10. Only numbers, decimal points, and minus (-) characters can be entered (no flashing)
<input onkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />
11. Only two decimal places and three decimal places can be entered (with flashing)
<input type="text" maxlength="9" onkeyup="if(value.match(/^/d{3}$/))value=value.replace(value,parseInt(value/10)) ;value= value.replace(//./d*/./g,'.')" onkeypress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 && event.keyCode!=45 || value.match(/^/d{3}$/) || //./d{3}$/.test(value)) {event.returnValue=false}" />