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,222
12년 전 조회 1,033
12년 전 조회 2,873
12년 전 조회 9,100
12년 전 조회 1,420
12년 전 조회 1,328
12년 전 조회 1,775
12년 전 조회 1,292
12년 전 조회 1,427
12년 전 조회 3,700
12년 전 조회 1,611
12년 전 조회 2,278
12년 전 조회 1,297
12년 전 조회 1,453
12년 전 조회 3,180
12년 전 조회 1,025
12년 전 조회 1,494
12년 전 조회 1,753
12년 전 조회 2,179
12년 전 조회 2,282
12년 전 조회 2,713
12년 전 조회 1,202
12년 전 조회 1,227
12년 전 조회 4,597
12년 전 조회 1,635
12년 전 조회 1,788
12년 전 조회 5,651
12년 전 조회 3,404
12년 전 조회 2,300
12년 전 조회 1,444
12년 전 조회 3,637
12년 전 조회 2,657
12년 전 조회 2,369
12년 전 조회 1,984
12년 전 조회 1,690
12년 전 조회 1,686
12년 전 조회 1,441
12년 전 조회 2,544
12년 전 조회 1,825
12년 전 조회 1,493
12년 전 조회 2,582
12년 전 조회 1,749
12년 전 조회 2,380
12년 전 조회 3,601
12년 전 조회 1,376
12년 전 조회 2,346
12년 전 조회 1,192
12년 전 조회 1,679
12년 전 조회 2,270
12년 전 조회 1,899
12년 전 조회 4,713
12년 전 조회 2,810
12년 전 조회 2,983
12년 전 조회 1,361
12년 전 조회 8,690
12년 전 조회 3,485
12년 전 조회 1,577
12년 전 조회 1,432
12년 전 조회 2,834
12년 전 조회 5,517
12년 전 조회 3,561
12년 전 조회 1,484
12년 전 조회 1.4만
12년 전 조회 1,352
12년 전 조회 756
12년 전 조회 4,082
12년 전 조회 1,587
12년 전 조회 9,488
12년 전 조회 927
12년 전 조회 1,383
12년 전 조회 3,368
12년 전 조회 991
12년 전 조회 1,908
12년 전 조회 3,801
12년 전 조회 1,220
12년 전 조회 1,125
12년 전 조회 5,448
12년 전 조회 1,580
12년 전 조회 903
12년 전 조회 2,758
12년 전 조회 2,631
12년 전 조회 1,660
12년 전 조회 3,068
12년 전 조회 6,689
12년 전 조회 2,291
12년 전 조회 885
12년 전 조회 2,052
12년 전 조회 2,002
12년 전 조회 2,756
12년 전 조회 744
12년 전 조회 1,835
12년 전 조회 931
12년 전 조회 1,909
12년 전 조회 2,829
12년 전 조회 1,386
12년 전 조회 4,017
12년 전 조회 1만
12년 전 조회 1,263
12년 전 조회 2,588
12년 전 조회 2,268
🐛 버그신고