function inNumber(){
if(event.keyCode<48 || event.keyCode>57){
event.returnValue=false;
}
}
출처: https://gocoder.tistory.com/111 [고코더 IT Express]
<input type="text" onKeyup="this.value=this.value.replace(/[^0-9]/g,'');"/>
출처: https://gocoder.tistory.com/111 [고코더 IT Express]
<html>
<head>
<script type="text/javascript">
function inNumber(){
if(event.keyCode<48 || event.keyCode>57){
event.returnValue=false;
}
}
</script>
</head>
<body>
<input type="text" onkeypress="inNumber();"/>
<input type="text" onKeyup="this.value=this.value.replace(/[^0-9]/g,'');"/>
</body>
</html>
출처: https://gocoder.tistory.com/111 [고코더 IT Express]
'study' 카테고리의 다른 글
javascript 문자열 길이 length (0) | 2019.07.13 |
---|---|
[제이쿼리][자바스크립트] 영문만, 숫자만, 한글만 입력. (0) | 2019.07.13 |
PHP header를 UTF-8로 설정하기 (0) | 2019.07.13 |
맥에 브라켓을 설치하다. (0) | 2019.07.10 |
맥프로 화면 캡쳐 (0) | 2019.07.10 |