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,703
12년 전 조회 1,478
12년 전 조회 3,337
12년 전 조회 9,565
12년 전 조회 1,874
12년 전 조회 1,829
12년 전 조회 2,272
12년 전 조회 1,747
12년 전 조회 1,930
12년 전 조회 4,209
12년 전 조회 2,102
12년 전 조회 2,769
12년 전 조회 1,764
12년 전 조회 1,940
12년 전 조회 3,642
12년 전 조회 1,489
12년 전 조회 1,964
12년 전 조회 2,281
12년 전 조회 2,711
12년 전 조회 2,824
12년 전 조회 3,263
12년 전 조회 1,722
12년 전 조회 1,764
12년 전 조회 5,148
12년 전 조회 2,196
12년 전 조회 2,368
12년 전 조회 6,205
12년 전 조회 3,900
12년 전 조회 2,866
12년 전 조회 2,019
12년 전 조회 4,183
12년 전 조회 3,208
12년 전 조회 2,868
12년 전 조회 2,552
12년 전 조회 2,244
12년 전 조회 2,252
12년 전 조회 1,993
12년 전 조회 3,076
12년 전 조회 2,394
12년 전 조회 2,095
12년 전 조회 3,156
12년 전 조회 2,354
12년 전 조회 2,927
12년 전 조회 4,141
12년 전 조회 1,906
12년 전 조회 2,887
12년 전 조회 1,742
12년 전 조회 2,226
12년 전 조회 2,869
12년 전 조회 2,473
12년 전 조회 5,278
12년 전 조회 3,394
12년 전 조회 3,583
12년 전 조회 1,941
12년 전 조회 9,274
12년 전 조회 4,081
12년 전 조회 2,152
12년 전 조회 2,005
12년 전 조회 3,444
12년 전 조회 6,117
12년 전 조회 4,140
12년 전 조회 2,058
12년 전 조회 1.4만
12년 전 조회 1,935
12년 전 조회 1,351
12년 전 조회 4,743
12년 전 조회 2,239
12년 전 조회 1만
12년 전 조회 1,523
12년 전 조회 2,012
12년 전 조회 3,972
12년 전 조회 1,609
12년 전 조회 2,509
12년 전 조회 4,498
12년 전 조회 1,799
12년 전 조회 1,693
12년 전 조회 6,065
12년 전 조회 2,195
12년 전 조회 1,529
12년 전 조회 3,271
12년 전 조회 3,252
12년 전 조회 2,239
12년 전 조회 3,655
12년 전 조회 7,342
12년 전 조회 2,922
12년 전 조회 1,475
13년 전 조회 2,652
13년 전 조회 2,617
13년 전 조회 3,351
13년 전 조회 1,332
13년 전 조회 2,437
13년 전 조회 1,535
13년 전 조회 2,510
13년 전 조회 3,429
13년 전 조회 2,031
13년 전 조회 4,628
13년 전 조회 1.1만
13년 전 조회 1,877
13년 전 조회 3,256
13년 전 조회 2,870