<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<title> allow multiple lines of text boxes to enter numbers and carriage returns JS code </title>
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<body>
<!--Add the following code to <body> and </body>-->
<textarea cols= "rows=" "style=" ime-mode:disabled "onkeyup=" Value=value.replace (/[^ d]/g, "") oncontextmenu= "Self.event.returnvalue=false" >
Instance Code two
Text boxes can only enter numbers '
Procedure tform1.edit1keypress (Sender:tobject; var key:char);
Begin
If not (key in [' 0 ' ... ') 9 ', #8, #13]) then
Begin
Key: = #0;
ShowMessage (' Input only number ');
End
End
Code Three
JS validation can only enter numbers.
function Check_validate1 (value) {
Defining the Regular Expression section
var reg =/^d+$/;
if (Value.constructor = = string) {
var re = Value.match (reg);
return true;
}
return false;
}
Example Four
<input name= "Selectid" type= "text" class= "input" size= "" style= "ime-mode:disabled" onkeydown= "if (EVENT.KEYC ode==13) event.keycode=9 "onkeypress=" if (Event.keycode <48 | | event.keycode>57)) Event.returnvalue=false ">
JS text box can only enter a number
A way to make a text box enter only numbers in a Web page. Plus return to change tab (Web Effects key key to use) + Prohibit switching Input method The first step is to use the style sheet.
<asp Tutorial: TextBox runat= "Server" id= "tt" style= "ime-mode:disabled" onkeydown= "Mykeydown ()" ></asp:textbox>
The second step is to use the JS script.
function Mykeydown () {
var k = Window.event.keycode; if ((k = = 46) | | (k = = 8) | | (k = = 189) | | (k = = 109) | | (k = = 190) | | (k = = 110) | | (k >= && k <= 57) | | (k >= && k <= 105) | | (k >= && K <= 40))
{ }
else if (k = = 13) {
Window.event.keycode = 9;
}
else {
Window.event.returnvalue = false;
}
}