Home >Web Front-end >JS Tutorial >JS input digital verification code_javascript skills

JS input digital verification code_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:48:591112browse

/*
**@The control can only input numbers, including - (negative sign). (decimal point)
**@Inline HTML: For Input
**@Event property: object. attachEvent("onkeypress",onlyNumber);object.style.imeMode = "disabled";
**@Author:wangwq@atools
*/
function onlyNumber(){
if(!( ((window.event.keyCode >= 48) && (window.event.keyCode || (window.event.keyCode == 13) || (window.event.keyCode == 46)
|| (window.event.keyCode == 45))){
window.event.keyCode = 0 ;
}
}
// This function is used to limit the text input box Only numbers "0" to "9" can be entered in
//@Inline HTML: For Input
//@Event property: object.attachEvent("onkeypress",JHshNumberText);object.style. imeMode = "disabled";
function JHshNumberText()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode {
window.event.keyCode = 0 ;
}
}

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