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,185
12년 전 조회 992
12년 전 조회 2,829
12년 전 조회 9,073
12년 전 조회 1,387
12년 전 조회 1,297
12년 전 조회 1,753
12년 전 조회 1,264
12년 전 조회 1,398
12년 전 조회 3,667
12년 전 조회 1,577
12년 전 조회 2,247
12년 전 조회 1,262
12년 전 조회 1,419
12년 전 조회 3,153
12년 전 조회 997
12년 전 조회 1,462
12년 전 조회 1,725
12년 전 조회 2,143
12년 전 조회 2,238
12년 전 조회 2,680
12년 전 조회 1,172
12년 전 조회 1,200
12년 전 조회 4,561
12년 전 조회 1,605
12년 전 조회 1,758
12년 전 조회 5,631
12년 전 조회 3,374
12년 전 조회 2,267
12년 전 조회 1,413
12년 전 조회 3,602
12년 전 조회 2,623
12년 전 조회 2,333
12년 전 조회 1,953
12년 전 조회 1,654
12년 전 조회 1,644
12년 전 조회 1,400
12년 전 조회 2,507
12년 전 조회 1,791
12년 전 조회 1,465
12년 전 조회 2,538
12년 전 조회 1,723
12년 전 조회 2,346
12년 전 조회 3,570
12년 전 조회 1,350
12년 전 조회 2,307
12년 전 조회 1,159
12년 전 조회 1,642
12년 전 조회 2,231
12년 전 조회 1,865
12년 전 조회 4,680
12년 전 조회 2,787
12년 전 조회 2,951
12년 전 조회 1,332
12년 전 조회 8,651
12년 전 조회 3,451
12년 전 조회 1,546
12년 전 조회 1,398
12년 전 조회 2,798
12년 전 조회 5,481
12년 전 조회 3,528
12년 전 조회 1,448
12년 전 조회 1.4만
12년 전 조회 1,307
12년 전 조회 722
12년 전 조회 4,044
12년 전 조회 1,562
12년 전 조회 9,464
12년 전 조회 891
12년 전 조회 1,350
12년 전 조회 3,332
12년 전 조회 957
12년 전 조회 1,878
12년 전 조회 3,775
12년 전 조회 1,190
12년 전 조회 1,080
12년 전 조회 5,413
12년 전 조회 1,546
12년 전 조회 872
12년 전 조회 2,752
12년 전 조회 2,594
12년 전 조회 1,620
12년 전 조회 3,035
12년 전 조회 6,656
12년 전 조회 2,254
12년 전 조회 847
12년 전 조회 2,023
12년 전 조회 1,973
12년 전 조회 2,719
12년 전 조회 717
12년 전 조회 1,801
12년 전 조회 895
12년 전 조회 1,880
12년 전 조회 2,798
12년 전 조회 1,357
12년 전 조회 3,989
12년 전 조회 1만
12년 전 조회 1,220
12년 전 조회 2,553
12년 전 조회 2,230
🐛 버그신고