테스트 사이트 - 개발 중인 베타 버전입니다

Key 관련

· 19년 전 · 2648 · 2
-------------------------------------------------------------------------------------------------------


한글만 입력받기


<script language='javascript'>
function hangul()
{
if((event.keyCode < 12592) || (event.keyCode > 12687))
event.returnValue = false
}
</script>

<input type="text" name="Name" size="10" maxlength="15" class=ad onKeyPress="hangul();">


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


input text 한영 한글/영문 입력 설정


<FORM>
<input style="ime-mode:active;">
<input style="ime-mode:inactive;">
</FORM>


ime-mode:active 이면 한글입력
ime-mode:inactive 이면 영문입력

익스플로러 6에서만 작동


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


한글 전환 모드 안 되게 하기

<input type="text" style="ime-mode:disabled;">


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


한영 한글/영문 전환 버튼

<html>
<head>

<script language="javascript">
<!--
function Kren(form)
{
if(form.test.style.imeMode == "active")
form.test.style.imeMode = "inactive";
else
form.test.style.imeMode = "active";
}
//-->
</script>

</head>

<body>

<form name=form1 action="">
<input type="text" name="test">
<input type="button" onClick="Kren(this.form)" value="한/영전환">
</form>
익스플로러 6이상에서만 작동합니다.
</body>
</html>


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


숫자만 입력받기

<script>
function num_only(){
if((event.keyCode<48) || (event.keyCode>57)){
event.returnValue=false;
}
}
</script>
<form name='test'>
<input type=text name='numInputField' OnKeyPress="num_only()" style="ime-mode:disabled">
</form>


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


전화번호 포맷으로 숫자만 입력하면 (02)123-3423 이런식으로 바꿔줍니다

<SCRIPT LANGUAGE="JavaScript">
<!--
///
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
pp=p;
d4=p.indexOf('(')
d5=p.indexOf(')')
if(d4==-1){
pp="("+pp;
}
if(d5==-1){
pp=pp+")";
}
document.frmPhone.txtphone.value="";
document.frmPhone.txtphone.value=pp;
}
if(p.length>3){
d1=p.indexOf('(')
d2=p.indexOf(')')
if (d2==-1){
l30=p.length;
p30=p.substring(0,4);
p30=p30+")"
p31=p.substring(4,l30);
pp=p30+p31;
document.frmPhone.txtphone.value="";
document.frmPhone.txtphone.value=pp;
}
}
if(p.length>5){
p11=p.substring(d1+1,d2);
if(p11.length>3){
p12=p11;
l12=p12.length;
l15=p.length
p13=p11.substring(0,3);
p14=p11.substring(3,l12);
p15=p.substring(d2+1,l15);
document.frmPhone.txtphone.value="";
pp="("+p13+")"+p14+p15;
document.frmPhone.txtphone.value=pp;
}
l16=p.length;
p16=p.substring(d2+1,l16);
l17=p16.length;
if(l17>3&&p16.indexOf('-')==-1){
p17=p.substring(d2+1,d2+4);
p18=p.substring(d2+4,l16);
p19=p.substring(0,d2+1);
pp=p19+p17+"-"+p18;
document.frmPhone.txtphone.value="";
document.frmPhone.txtphone.value=pp;
}
}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=m.name;
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
//-->
</script>
전화번호보단 다른 데 응용하시면 좋을 듯..<br>태그인넷 tagin.net<br>
<form name=frmPhone>
<input type=text name=txtphone maxlength="13" onclick="javascript:getIt(this)" >
</form>


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


입력박스 폼안의 숫자 1000단위로 자동 ,콤마 찍어주기

<SCRIPT LANGUAGE="JavaScript">
<!--
function Number_Format(fn){
var str = fn.value;
var Re = /[^0-9]/g;
var ReN = /(-?[0-9]+)([0-9]{3})/;
str = str.replace(Re,'');
while (ReN.test(str)) {
str = str.replace(ReN, "$1,$2");
}
fn.value = str;
}
//-->
</SCRIPT>

<FORM name=fm METHOD=POST ACTION="">
<INPUT TYPE="text" NAME="money" Onkeyup="Number_Format(this)";>
</FORM>


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


특수문자 입력금지

<center>
<form onSubmit="return false;">
<a href="http://tagin.net">특수문자를 입력 할 수 없습니다: (예 !@#$%^&* etc)<br>
<textarea rows=2 cols=20 name=comments onKeypress="if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) event.returnValue = false;"></textarea>
<br>
<br>
홋(겹)따옴표를 입력 할 수 없습니다:<br>
<input type=text name=txtEmail onKeypress="if (event.keyCode==34 || event.keyCode==39) event.returnValue = false;">
<br>
<br>
숫자만 입력가능합니다:<br>
<input type=text name=txtPostalCode onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">
</a></form>
</center>


-------------------------------------------------------------------------------------------------------<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 2개

감사합니다......
한글만 입력받기는 끝말잇기 게시판에 적용을.. 후후
좋은 팁 감사합니다. ^^

게시글 목록

번호 제목
9921
28612
28611
28605
9920
JavaScript Samba 설정
9916
9915
28596
9906
28572
HTML if 23
28564
9898
24744
24742
24741
24736
28558
9896
9893
9892
9891
9890
28557
9889
9888
9887
9885
9884
28555
9883
9881
9880
9879
9878
9877
9876
9873
9871
9864
9840
9836
9834
9832
9830
9828
9826
9797
9754
9709
9686
9646
9634
9617
9615
9613
28553
9611
9607
24726
24725
24721
9569
9567
9550
9531
9527
28550
9493
9479
9431
9418
9372
9331
9267
9216
9215
9214
28549
28548
9213
28543
9211
9210
9208
24718
24706
24702
24701
24698
24695
9202
28540
24688
9194
24679
24674
24670
9193
9191
9190