Jquery

input number 형식 maxlength 정하기

SeoHW 2018. 11. 29. 09:46
SMALL

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>


<script type="text/javascript">

  function maxLengthCheck(object){

    if (object.value.length > object.maxLength){

      object.value = object.value.slice(0, object.maxLength);

    }    

  }

  

</script>


<input type="number" maxlength="4" oninput="maxLengthCheck(this)"/>

출처 : http://milkye.tistory.com/265

LIST