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년 전 조회 1,123
12년 전 조회 937
12년 전 조회 2,778
12년 전 조회 9,023
12년 전 조회 1,339
12년 전 조회 1,229
12년 전 조회 1,694
12년 전 조회 1,202
12년 전 조회 1,346
12년 전 조회 3,616
12년 전 조회 1,520
12년 전 조회 2,194
12년 전 조회 1,212
12년 전 조회 1,361
12년 전 조회 3,086
12년 전 조회 941
12년 전 조회 1,412
12년 전 조회 1,674
12년 전 조회 2,090
12년 전 조회 2,191
12년 전 조회 2,629
12년 전 조회 1,113
12년 전 조회 1,138
12년 전 조회 4,507
12년 전 조회 1,555
12년 전 조회 1,696
12년 전 조회 5,561
12년 전 조회 3,320
12년 전 조회 2,199
12년 전 조회 1,356
12년 전 조회 3,544
12년 전 조회 2,581
12년 전 조회 2,277
12년 전 조회 1,897
12년 전 조회 1,599
12년 전 조회 1,594
12년 전 조회 1,339
12년 전 조회 2,458
12년 전 조회 1,732
12년 전 조회 1,417
12년 전 조회 2,490
12년 전 조회 1,672
12년 전 조회 2,287
12년 전 조회 3,508
12년 전 조회 1,297
12년 전 조회 2,266
12년 전 조회 1,103
12년 전 조회 1,585
12년 전 조회 2,172
12년 전 조회 1,814
12년 전 조회 4,619
12년 전 조회 2,721
12년 전 조회 2,894
12년 전 조회 1,285
12년 전 조회 8,591
12년 전 조회 3,386
12년 전 조회 1,492
12년 전 조회 1,340
12년 전 조회 2,741
12년 전 조회 5,419
12년 전 조회 3,471
12년 전 조회 1,393
12년 전 조회 1.4만
12년 전 조회 1,254
12년 전 조회 661
12년 전 조회 3,986
12년 전 조회 1,514
12년 전 조회 9,403
12년 전 조회 837
12년 전 조회 1,294
12년 전 조회 3,267
12년 전 조회 898
12년 전 조회 1,818
12년 전 조회 3,711
12년 전 조회 1,128
12년 전 조회 1,015
12년 전 조회 5,362
12년 전 조회 1,491
12년 전 조회 810
12년 전 조회 2,741
12년 전 조회 2,543
12년 전 조회 1,561
12년 전 조회 2,991
12년 전 조회 6,604
12년 전 조회 2,198
12년 전 조회 792
12년 전 조회 1,958
12년 전 조회 1,911
12년 전 조회 2,665
12년 전 조회 657
12년 전 조회 1,741
12년 전 조회 824
12년 전 조회 1,825
12년 전 조회 2,738
12년 전 조회 1,293
12년 전 조회 3,933
12년 전 조회 1만
12년 전 조회 1,165
12년 전 조회 2,498
12년 전 조회 2,173
🐛 버그신고