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,261
12년 전 조회 1,070
12년 전 조회 2,907
12년 전 조회 9,142
12년 전 조회 1,456
12년 전 조회 1,371
12년 전 조회 1,824
12년 전 조회 1,330
12년 전 조회 1,467
12년 전 조회 3,747
12년 전 조회 1,660
12년 전 조회 2,328
12년 전 조회 1,350
12년 전 조회 1,495
12년 전 조회 3,220
12년 전 조회 1,070
12년 전 조회 1,535
12년 전 조회 1,795
12년 전 조회 2,224
12년 전 조회 2,328
12년 전 조회 2,755
12년 전 조회 1,235
12년 전 조회 1,261
12년 전 조회 4,643
12년 전 조회 1,682
12년 전 조회 1,833
12년 전 조회 5,695
12년 전 조회 3,435
12년 전 조회 2,337
12년 전 조회 1,490
12년 전 조회 3,677
12년 전 조회 2,706
12년 전 조회 2,412
12년 전 조회 2,042
12년 전 조회 1,731
12년 전 조회 1,725
12년 전 조회 1,479
12년 전 조회 2,596
12년 전 조회 1,875
12년 전 조회 1,546
12년 전 조회 2,631
12년 전 조회 1,810
12년 전 조회 2,429
12년 전 조회 3,644
12년 전 조회 1,430
12년 전 조회 2,385
12년 전 조회 1,240
12년 전 조회 1,731
12년 전 조회 2,308
12년 전 조회 1,941
12년 전 조회 4,760
12년 전 조회 2,860
12년 전 조회 3,032
12년 전 조회 1,406
12년 전 조회 8,727
12년 전 조회 3,539
12년 전 조회 1,627
12년 전 조회 1,488
12년 전 조회 2,876
12년 전 조회 5,557
12년 전 조회 3,609
12년 전 조회 1,540
12년 전 조회 1.4만
12년 전 조회 1,403
12년 전 조회 813
12년 전 조회 4,122
12년 전 조회 1,628
12년 전 조회 9,524
12년 전 조회 989
12년 전 조회 1,436
12년 전 조회 3,408
12년 전 조회 1,049
12년 전 조회 1,949
12년 전 조회 3,853
12년 전 조회 1,258
12년 전 조회 1,163
12년 전 조회 5,499
12년 전 조회 1,628
12년 전 조회 956
12년 전 조회 2,774
12년 전 조회 2,686
12년 전 조회 1,701
12년 전 조회 3,141
12년 전 조회 6,748
12년 전 조회 2,341
12년 전 조회 944
12년 전 조회 2,107
12년 전 조회 2,035
12년 전 조회 2,807
12년 전 조회 796
12년 전 조회 1,892
12년 전 조회 979
12년 전 조회 1,957
12년 전 조회 2,885
12년 전 조회 1,438
12년 전 조회 4,071
12년 전 조회 1만
12년 전 조회 1,306
12년 전 조회 2,640
12년 전 조회 2,326