The article has a collection of JS input can only enter a number (compatible with IE and Firefox) is regular, the front two is online to find but seems to not support Ie,firefox regular, and later a very beautiful compatible with multiple browsing the regular method ha.
Only numbers can be entered
<input onkeyup= "value="/value.replace (/["^d]/g") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^d]/g, ') ">
You can only enter a number to lose a decimal point.
<inputōnkeyup= ' if (isNaN (value)) ExecCommand (' Undo ') ' ōnafterpaste= ' if (isNaN (value)) ExecCommand (' Undo ') >
<input name=txt1ōnchange= "if (/d/.test (this.value)) {alert (' can only enter a number '); this.value= ';} ' >
To see a number of instances that can only be entered
Input can only enter the number of online search is for IE, wrote a generic.
Using a jquery method to determine if IE is not
Isnumber = function (e) {
if ($.browser.msie) {
if ((Event.keycode >) && (Event.keycode < 58) | |
(Event.keycode = = 8) {
return true;
} else {
return false;
}
} else {
if ((E.which >) & & (E.which < 58)) | |
(E.which = 8)) {
return true;
} else {
return false;
}
}
} html code
<input type= "text" onkeypress= "Web Effects: Return Isnumber (event);" />&NBSP