TIP

숫자만 입력받기 예제

[code]<tr> 

    <th scope="row"><label for="wr_1"><span class="sound_only">번호입력</span><i class="fa fa-address-card" aria-hidden="true"></i> 번호입력</label></th>

    <td><input type="text" name="wr_1" value="<?php echo $wr_1 ?>" id="wr_1" required class="frm_input required" size="50" maxlength="4" placeholder="차량번호"onkeydown='return onlyNumber(event)' onkeyup='removeChar(event)' style='ime-mode:disabled;'> &nbsp;&nbsp;&nbsp;&nbsp;숫자 4자리만 써주세요.</td>

</tr>


<script>

function onlyNumber(event){

event = event || window.event;

var keyID = (event.which) ? event.which : event.keyCode;

if ( (keyID >= 48 && keyID <= 57) || (keyID >= 96 && keyID <= 105) || keyID == 8 || keyID == 46 || keyID == 37 || keyID == 39 ) 

return;

else

return false;

}

function removeChar(event) {

event = event || window.event;

var keyID = (event.which) ? event.which : event.keyCode;

if ( keyID == 8 || keyID == 46 || keyID == 37 || keyID == 39 ) 

return;

else

event.target.value = event.target.value.replace(/[^0-9]/g, "");

}

</script>[/code]

댓글목록

등록된 댓글이 없습니다.