특수문자 입력방지

beomhak lee·2024년 8월 7일

work_tip

목록 보기
31/37
<input type="text" id="text" name="text" onkeyup="characterCheck(this)" onkeydown="characterCheck(this)" >
// 특수문자 입력 방지
function characterCheck(obj){
var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=]/gi; 
if( regExp.test(obj.value) ){
	
	obj.value = obj.value.substring( 0 , obj.value.length - 1 ); // 입력한 특수문자 한자리 지움
	}
}

0개의 댓글