s

자바스크립트 폼체크에서 해방되세요//

<?

function sendIt($f,$arr,$opt="",$preOpt="") {
$RE="function sendIt(f) {";
$RE.=$preOpt;
while (list($key,$val)=each($arr)) {
$RE.="
if (!document.".$f.".".$key.".disabled) {
";
$RE.="
if (document.".$f.".".$key.".value=='') {
alert('".$val."(을)를 입력해 주세요');
document.".$f.".".$key.".focus(); return false;
}
";
$RE.="
}
";
}
$RE.=$opt;
$RE.="document.".$f.".submit();";
$RE.="}";
return $RE;
}

//사용예제
?>

<script language=javascript>
<?
$arr=array("company"=>"회사","name"=>"이름","tel"=>"전화번호");
echo sendIt("form1",$arr);
?>
</script>
<form name=form1 action='<?=$PHP_SELF?>'>
회사 : <input name=company><br>
이름 : <input name=name><br>
전화 : <input name=tel><br>
<input type=button onclick='sendIt(this.form);' value='확인'>
</form>
01<?
02
03 function sendIt($f,$arr,$opt="",$preOpt="") {
04 $RE="function sendIt(f) {";
05 $RE.=$preOpt;
06 while (list($key,$val)=each($arr)) {
07 $RE.="
08 if (!document.".$f.".".$key.".disabled) {
09 ";
10 $RE.="
11 if (document.".$f.".".$key.".value=='') {
12 alert('".$val."(을)를 입력해 주세요');
13 document.".$f.".".$key.".focus(); return false;
14 }
15 ";
16 $RE.="
17 }
18 ";
19 }
20 $RE.=$opt;
21 $RE.="document.".$f.".submit();";
22 $RE.="}";
23 return $RE;
24 }
25
26//사용예제
27?>
28
29<script language=javascript>
30<?
31$arr=array("company"=>"회사","name"=>"이름","tel"=>"전화번호");
32echo sendIt("form1",$arr);
33?>
34</script>
35<form name=form1 action='<?=$PHP_SELF?>'>
36회사 : <input name=company>
37이름 : <input name=name>
38전화 : <input name=tel>
39<input type=button onclick='sendIt(this.form);' value='확인'>
40</form>
|

댓글 1개

와 좋네요 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
12년 전 조회 2,234
12년 전 조회 2,050
12년 전 조회 3,828
12년 전 조회 1만
12년 전 조회 2,401
12년 전 조회 2,341
12년 전 조회 2,784
12년 전 조회 2,250
12년 전 조회 2,402
12년 전 조회 4,679
12년 전 조회 2,622
12년 전 조회 3,290
12년 전 조회 2,288
12년 전 조회 2,442
12년 전 조회 4,164
12년 전 조회 2,023
12년 전 조회 2,512
12년 전 조회 2,829
12년 전 조회 3,268
12년 전 조회 3,380
12년 전 조회 3,845
13년 전 조회 2,279
13년 전 조회 2,290
13년 전 조회 5,685
13년 전 조회 2,743
13년 전 조회 2,912
13년 전 조회 6,771
13년 전 조회 4,482
13년 전 조회 3,410
13년 전 조회 2,601
13년 전 조회 4,765
13년 전 조회 3,756
13년 전 조회 3,451
13년 전 조회 3,098
13년 전 조회 2,796
13년 전 조회 2,780
13년 전 조회 2,510
13년 전 조회 3,643
13년 전 조회 2,938
13년 전 조회 2,594
13년 전 조회 3,659
13년 전 조회 2,873
13년 전 조회 3,475
13년 전 조회 4,703
13년 전 조회 2,462
13년 전 조회 3,451
13년 전 조회 2,285
13년 전 조회 2,746
13년 전 조회 3,379
13년 전 조회 3,027
13년 전 조회 5,812
13년 전 조회 3,935
13년 전 조회 4,123
13년 전 조회 2,468
13년 전 조회 9,799
13년 전 조회 4,642
13년 전 조회 2,702
13년 전 조회 2,562
13년 전 조회 3,947
13년 전 조회 6,672
13년 전 조회 4,685
13년 전 조회 2,609
13년 전 조회 1.5만
13년 전 조회 2,482
13년 전 조회 1,911
13년 전 조회 5,144
13년 전 조회 2,635
13년 전 조회 1.1만
13년 전 조회 2,087
13년 전 조회 2,455
13년 전 조회 4,532
13년 전 조회 2,140
13년 전 조회 3,040
13년 전 조회 4,961
13년 전 조회 2,350
13년 전 조회 2,246
13년 전 조회 6,609
13년 전 조회 2,707
13년 전 조회 2,030
13년 전 조회 3,795
13년 전 조회 3,811
13년 전 조회 2,774
13년 전 조회 4,212
13년 전 조회 7,879
13년 전 조회 3,440
13년 전 조회 2,045
13년 전 조회 3,199
13년 전 조회 3,135
13년 전 조회 3,912
13년 전 조회 1,895
13년 전 조회 2,998
13년 전 조회 1,997
13년 전 조회 3,077
13년 전 조회 3,987
13년 전 조회 2,433
13년 전 조회 5,176
13년 전 조회 1.1만
13년 전 조회 2,437
13년 전 조회 3,792
13년 전 조회 3,400