1. 연락처 입력 시 숫자만 받기


<input type="text" id="txtPhone" maxlength="4" onKeyUp="chk_Number(this); />

function chk_Number(object){
$(object).keyup(function(){
$(this).val($(this).val().replace(/[^0-9]/g,""));
});   
}


2. 데이터 존재 여부 체크 


<input type="text" name="inputId" id="inputId" maxlength="10"/>

if(!$('#inputId').val()){
alert("값을 입력해 주세요.");
$('#inputId').focus();
return false;
}


3. 데이터 길이 제한 체크


<input type="text" name="inputId" id="inputId" maxlength="10"/>
if($('#inputId').val().length < 2 || $('#inputId').val().length > 10){
alert("InputId 태그의 길이는 2자~10자입니다.");
$('#inputId').focus();
return false;


'웹 클라이언트 > Jquery' 카테고리의 다른 글

Jquery 값 얻기 (Select, Input)  (0) 2017.09.04
Posted by Hoya0415
,