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,359
12년 전 조회 2,167
12년 전 조회 3,967
12년 전 조회 1만
12년 전 조회 2,528
12년 전 조회 2,475
12년 전 조회 2,912
12년 전 조회 2,373
12년 전 조회 2,548
12년 전 조회 4,806
12년 전 조회 2,757
12년 전 조회 3,414
12년 전 조회 2,404
12년 전 조회 2,581
12년 전 조회 4,305
13년 전 조회 2,148
13년 전 조회 2,643
13년 전 조회 2,951
13년 전 조회 3,395
13년 전 조회 3,503
13년 전 조회 3,950
13년 전 조회 2,408
13년 전 조회 2,420
13년 전 조회 5,803
13년 전 조회 2,859
13년 전 조회 3,033
13년 전 조회 6,911
13년 전 조회 4,605
13년 전 조회 3,526
13년 전 조회 2,710
13년 전 조회 4,892
13년 전 조회 3,874
13년 전 조회 3,566
13년 전 조회 3,246
13년 전 조회 2,935
13년 전 조회 2,912
13년 전 조회 2,662
13년 전 조회 3,793
13년 전 조회 3,087
13년 전 조회 2,722
13년 전 조회 3,801
13년 전 조회 3,015
13년 전 조회 3,598
13년 전 조회 4,834
13년 전 조회 2,593
13년 전 조회 3,566
13년 전 조회 2,405
13년 전 조회 2,876
13년 전 조회 3,500
13년 전 조회 3,144
13년 전 조회 5,940
13년 전 조회 4,048
13년 전 조회 4,229
13년 전 조회 2,607
13년 전 조회 9,932
13년 전 조회 4,761
13년 전 조회 2,822
13년 전 조회 2,686
13년 전 조회 4,084
13년 전 조회 6,804
13년 전 조회 4,806
13년 전 조회 2,725
13년 전 조회 1.5만
13년 전 조회 2,611
13년 전 조회 2,028
13년 전 조회 5,199
13년 전 조회 2,670
13년 전 조회 1.1만
13년 전 조회 2,212
13년 전 조회 2,510
13년 전 조회 4,640
13년 전 조회 2,258
13년 전 조회 3,149
13년 전 조회 5,077
13년 전 조회 2,456
13년 전 조회 2,366
13년 전 조회 6,743
13년 전 조회 2,847
13년 전 조회 2,158
13년 전 조회 3,911
13년 전 조회 3,930
13년 전 조회 2,903
13년 전 조회 4,336
13년 전 조회 8,001
13년 전 조회 3,551
13년 전 조회 2,166
13년 전 조회 3,307
13년 전 조회 3,260
13년 전 조회 4,022
13년 전 조회 2,017
13년 전 조회 3,117
13년 전 조회 2,051
13년 전 조회 3,182
13년 전 조회 4,105
13년 전 조회 2,485
13년 전 조회 5,316
13년 전 조회 1.1만
13년 전 조회 2,558
13년 전 조회 3,922
13년 전 조회 3,527