특수문자 막는 스크립트
본문
<scRIPT LANGUAGE="Javascript">
<!--
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
}
}
function doanothercheck(form) {
if(form.value.length < 1) {
alert("입력해 주십시요.");
return false;
}
if(form.value.search(mikExp) == -1) {
alert("정확히 입력 하셨습니다.");
return false;
}
else {
alert("다음과 같은 특수문자는 \n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ = | \n\r\n\r입력하시면 안됩
니다\n");
form.select();
form.focus();
return false;
}
alert("정확히 입력 하셨습니다.");
return false;
}
// -->
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER><form name=xyz onSubmit="return doanothercheck(this.txtTerm);">
<input type="text" name="txtTerm" size="35" maxlength="50" value="" onKeyUp="javascript:dodacheck
(xyz.txtTerm);">
<br>
<input type=submit value=Check>
</form></CENTER
출처 : http://www.aircon1004.com/data/bbs/board.php?bo_table=pds1&wr_id=155
<!--
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
}
}
function doanothercheck(form) {
if(form.value.length < 1) {
alert("입력해 주십시요.");
return false;
}
if(form.value.search(mikExp) == -1) {
alert("정확히 입력 하셨습니다.");
return false;
}
else {
alert("다음과 같은 특수문자는 \n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ = | \n\r\n\r입력하시면 안됩
니다\n");
form.select();
form.focus();
return false;
}
alert("정확히 입력 하셨습니다.");
return false;
}
// -->
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER><form name=xyz onSubmit="return doanothercheck(this.txtTerm);">
<input type="text" name="txtTerm" size="35" maxlength="50" value="" onKeyUp="javascript:dodacheck
(xyz.txtTerm);">
<br>
<input type=submit value=Check>
</form></CENTER
출처 : http://www.aircon1004.com/data/bbs/board.php?bo_table=pds1&wr_id=155
관련링크
댓글목록
등록된 댓글이 없습니다.