-
글자 수 체크 및 카운트현재/JavaScript 2021. 4. 1. 14:27
1. 개요
1) 이벤트 등록 페이지 내 글자 수 체크해서 카운트 해주는 이벤트
2. 구현
1) js
$('#evButtonName').on('keyup', function(){ // 글자수 카운트 $('#buttonNameCountChk').html("("+$(this).val().length+ " / 10)"); // 10자까지만 표현 if($(this).val().length > 10) { $(this).val($(this).val().substring(0, 10)); $('#buttonNameCountChk').html("(10 / 10)"); } });
2) html<td class="input"> <input type="text" id="evButtonName" name="evButtonName" class="ui-input" title="버튼명 입력" placeholder="10자 이내로 입력" maxlength="10" value="${evEvent.evtBenefitApplyButton}"> <span> <ul class="td-text-list"> <li id="buttonNameCountChk">(0 / 10)</li> </ul> </span> </td>
'현재 > JavaScript' 카테고리의 다른 글
ECMAScript2015 (ES6) (0) 2021.11.04 spread operator (0) 2021.09.23 랜덤 위치 노출 (0) 2021.03.29 setInterval, clearInterval, setTimeout (0) 2021.03.26