Can only enter the text box of numbers

xiaoxiao2021-03-06  69

1. / *** Check the keyboard event, only the input number * @return: true / false check success / failed * @Author: LCW * / Function iskeyNumber () {var s_keycode = (navigator.appname == "netscape" )? Event.Which: Event.keycode; if ((s_keycode> = 48 && s_keycode <= 57) || s_keycode == 32 || s_keycode == 9 || s_keycode == 13 || s_keycode == 8 || S_KeyCode == 46) {return true;}}} 2 ./*** Check INPUT input, only entered the number * @return: true / false check success / failed * @Author: LCW * / Function ISNumber (string) {var temp_str = "0123456789"; var checkresult = true; var cliff = true; var i; var ch; for (i = 0; i

Inadvertently found such something, please build a blank html page, enter the following code: You will find this is A text box that can only enter the number of regular verification of the number, I think about this should be a JavaScript? But I found some articles of JavaScript regimen that it can't be used, but the above things can be parsed correctly in IE6 and Firefox 1.0. Who can tell me if you have HTML or script? This thing is good, but there is also a shortcomings, such as the biggest problem is the direction button on the keyboard, and the previous data will be emptied with Microsoft Pinyin 2003. Later, I tried to change Onkeyup to ONCHANGE, this above is solved, but verification will only be generated when the focus is lost, but this is no relationship. Is it easy to verify now? Copy a few regular expressions, you can refer to: You can only enter digital and English / [/ w] / g can only enter digital / [^ / d] / g can only enter Chinese characters / [^ / U4E00- / u9fa5] / g

Example: ----------------------- ------------------------------------- Bulk ~~ I just found a bug, that is The Input control has a memory function, and it is not ONBLUER, which is not ONBLUR, but it is ok. It is normal, it is to lose the focus. Correct example:

转载请注明原文地址:https://www.9cbs.com/read-92407.html

New Post(0)