Home >Web Front-end >JS Tutorial >Only scripts that are smaller than the maximum number and are positive integers can be entered_Form special effects

Only scripts that are smaller than the maximum number and are positive integers can be entered_Form special effects

WBOY
WBOYOriginal
2016-05-16 19:22:251019browse

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]<script> /* 只允许输入数字 */ function numInputCheck(o,m){ var d; if(',48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,8,9,13,'.indexOf(',' + event.keyCode + ',')==-1){ event.returnValue=null; } if(m!=null){ d = event.keyCode >= 96 ? event.keyCode - 48 : event.keyCode; if(document.selection.createRange().duplicate().text=='' && (o.value+String.fromCharCode(d))>m){ event.returnValue=null;o.value=m; }else if(',8,9,13,'.indexOf(',' + d + ',')==-1&&document.selection.createRange().duplicate().text==''&&o.value.indexOf('0')==0){ o.value=''; } } } </script>
Statement:
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