취업/자바스크립트
[JS] input 숫자만 또는 숫자, 영문만 입력하게하기
카슈밀
2022. 11. 16. 08:34
반응형
<input
type="text"
oninput="this.value = this.value.replace(/[^0-9^A-Za-z]/g, '').replace(/(\..*)\./g, '$1');"
/>
해당부분으로 입력시 영어와 숫자만 입력되고 나머진 입력이 애초에 되지 않는다.
<input
type="text"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"
/>
숫자와 점만 입력하게 하기
<input
type="text"
oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/(\..*)\./g, '$1');"
/>
숫자만 입력하게 하기.
이상 끝.
728x90