Preliminary knowledge 1. Number 0 key value 48. Number 9 key value 57 2.a Key value 97..z key value 122; A key value 65..Z key value 90 3. Key value 43; - key value 45;. key value 46; backspace 8; tab key value 9; 4.event is global in IE and is a temporary object in Firefox, and parameters need to be passed */
jQuery.extend({ /*========= ================================================== ================ Function description: Get the value of the key Calling method: jQuery.getKeyNum(event); */ getKeyNum:function(e){ var keynum; if(window.event){ // IE keynum = event.keyCode; } else if(e.which){ // Netscape/Firefox/Opera keynum = e.which; } return keynum; }, /*============== ================================================== =========== Function description: Determine whether it is an integer, restrict the edit box to only input numbers Calling method:
Problems to be solved: The tab key does not work in Firefox. */ isInt:function(e){ var keynum = this.getKeyNum(e); if(keynum >= 48 && keynum <= 57 || keynum == 8 ){//Backspace under firefox needs to be judged 8 return true; } return false; }, /*============= ================================================== ============ Function description: Determine whether it is a decimal. Limit the edit box to only numbers and one decimal point. Calling method:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn