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,415
13년 전 조회 2,217
13년 전 조회 4,022
13년 전 조회 1만
13년 전 조회 2,590
13년 전 조회 2,533
13년 전 조회 2,980
13년 전 조회 2,423
13년 전 조회 2,604
13년 전 조회 4,864
13년 전 조회 2,812
13년 전 조회 3,468
13년 전 조회 2,469
13년 전 조회 2,645
13년 전 조회 4,369
13년 전 조회 2,209
13년 전 조회 2,711
13년 전 조회 3,010
13년 전 조회 3,453
13년 전 조회 3,566
13년 전 조회 4,017
13년 전 조회 2,471
13년 전 조회 2,482
13년 전 조회 5,873
13년 전 조회 2,920
13년 전 조회 3,087
13년 전 조회 6,963
13년 전 조회 4,661
13년 전 조회 3,592
13년 전 조회 2,766
13년 전 조회 4,945
13년 전 조회 3,959
13년 전 조회 3,637
13년 전 조회 3,312
13년 전 조회 2,998
13년 전 조회 2,965
13년 전 조회 2,727
13년 전 조회 3,849
13년 전 조회 3,159
13년 전 조회 2,784
13년 전 조회 3,869
13년 전 조회 3,080
13년 전 조회 3,671
13년 전 조회 4,896
13년 전 조회 2,653
13년 전 조회 3,617
13년 전 조회 2,460
13년 전 조회 2,951
13년 전 조회 3,561
13년 전 조회 3,204
13년 전 조회 6,013
13년 전 조회 4,122
13년 전 조회 4,283
13년 전 조회 2,677
13년 전 조회 9,989
13년 전 조회 4,810
13년 전 조회 2,883
13년 전 조회 2,757
13년 전 조회 4,148
13년 전 조회 6,872
13년 전 조회 4,863
13년 전 조회 2,790
13년 전 조회 1.5만
13년 전 조회 2,668
13년 전 조회 2,092
13년 전 조회 5,229
13년 전 조회 2,703
13년 전 조회 1.1만
13년 전 조회 2,277
13년 전 조회 2,539
13년 전 조회 4,716
13년 전 조회 2,328
13년 전 조회 3,231
13년 전 조회 5,147
13년 전 조회 2,522
13년 전 조회 2,426
13년 전 조회 6,811
13년 전 조회 2,905
13년 전 조회 2,223
13년 전 조회 3,967
13년 전 조회 3,995
13년 전 조회 2,968
13년 전 조회 4,412
13년 전 조회 8,073
13년 전 조회 3,625
13년 전 조회 2,238
13년 전 조회 3,381
13년 전 조회 3,329
13년 전 조회 4,086
13년 전 조회 2,095
13년 전 조회 3,185
13년 전 조회 2,081
13년 전 조회 3,254
13년 전 조회 4,168
13년 전 조회 2,517
13년 전 조회 5,375
13년 전 조회 1.2만
13년 전 조회 2,609
13년 전 조회 4,002
13년 전 조회 3,601