본문 바로가기

js

input 타입 text 에 숫자만 받아들이기

html

<input type="text" numberOnly/>

 

//js 

$("input:text[numberOnly]").on("keypress keyup blur", function() {
  $(this).val($(this).val().replace(/[^0-9]/g,""));
});