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개

와 좋네요 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
13년 전 조회 2,450
13년 전 조회 2,249
13년 전 조회 4,062
13년 전 조회 1만
13년 전 조회 2,629
13년 전 조회 2,577
13년 전 조회 3,021
13년 전 조회 2,469
13년 전 조회 2,630
13년 전 조회 4,908
13년 전 조회 2,863
13년 전 조회 3,513
13년 전 조회 2,500
13년 전 조회 2,677
13년 전 조회 4,412
13년 전 조회 2,248
13년 전 조회 2,742
13년 전 조회 3,053
13년 전 조회 3,489
13년 전 조회 3,601
13년 전 조회 4,051
13년 전 조회 2,498
13년 전 조회 2,520
13년 전 조회 5,914
13년 전 조회 2,959
13년 전 조회 3,125
13년 전 조회 6,999
13년 전 조회 4,687
13년 전 조회 3,634
13년 전 조회 2,807
13년 전 조회 4,984
13년 전 조회 3,996
13년 전 조회 3,673
13년 전 조회 3,355
13년 전 조회 3,029
13년 전 조회 3,001
13년 전 조회 2,765
13년 전 조회 3,892
13년 전 조회 3,203
13년 전 조회 2,823
13년 전 조회 3,911
13년 전 조회 3,113
13년 전 조회 3,715
13년 전 조회 4,932
13년 전 조회 2,696
13년 전 조회 3,659
13년 전 조회 2,495
13년 전 조회 2,988
13년 전 조회 3,598
13년 전 조회 3,255
13년 전 조회 6,054
13년 전 조회 4,166
13년 전 조회 4,341
13년 전 조회 2,721
13년 전 조회 1만
13년 전 조회 4,851
13년 전 조회 2,926
13년 전 조회 2,805
13년 전 조회 4,193
13년 전 조회 6,917
13년 전 조회 4,914
13년 전 조회 2,836
13년 전 조회 1.5만
13년 전 조회 2,714
13년 전 조회 2,145
13년 전 조회 5,247
13년 전 조회 2,724
13년 전 조회 1.1만
13년 전 조회 2,327
13년 전 조회 2,566
13년 전 조회 4,768
13년 전 조회 2,373
13년 전 조회 3,284
13년 전 조회 5,200
13년 전 조회 2,568
13년 전 조회 2,473
13년 전 조회 6,859
13년 전 조회 2,951
13년 전 조회 2,273
13년 전 조회 4,021
13년 전 조회 4,054
13년 전 조회 3,023
13년 전 조회 4,459
13년 전 조회 8,119
13년 전 조회 3,685
13년 전 조회 2,291
13년 전 조회 3,423
13년 전 조회 3,386
13년 전 조회 4,142
13년 전 조회 2,140
13년 전 조회 3,241
13년 전 조회 2,095
13년 전 조회 3,311
13년 전 조회 4,210
13년 전 조회 2,547
13년 전 조회 5,433
13년 전 조회 1.2만
13년 전 조회 2,668
13년 전 조회 4,056
13년 전 조회 3,659