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,190
12년 전 조회 2,004
12년 전 조회 3,798
12년 전 조회 1만
12년 전 조회 2,359
12년 전 조회 2,302
12년 전 조회 2,747
12년 전 조회 2,217
12년 전 조회 2,366
12년 전 조회 4,640
12년 전 조회 2,591
12년 전 조회 3,248
12년 전 조회 2,245
12년 전 조회 2,411
12년 전 조회 4,134
12년 전 조회 1,973
12년 전 조회 2,472
12년 전 조회 2,794
12년 전 조회 3,226
12년 전 조회 3,336
12년 전 조회 3,811
13년 전 조회 2,242
13년 전 조회 2,265
13년 전 조회 5,646
13년 전 조회 2,712
13년 전 조회 2,876
13년 전 조회 6,731
13년 전 조회 4,449
13년 전 조회 3,370
13년 전 조회 2,554
13년 전 조회 4,723
13년 전 조회 3,713
13년 전 조회 3,416
13년 전 조회 3,062
13년 전 조회 2,760
13년 전 조회 2,744
13년 전 조회 2,485
13년 전 조회 3,612
13년 전 조회 2,908
13년 전 조회 2,565
13년 전 조회 3,619
13년 전 조회 2,833
13년 전 조회 3,436
13년 전 조회 4,670
13년 전 조회 2,435
13년 전 조회 3,420
13년 전 조회 2,248
13년 전 조회 2,712
13년 전 조회 3,348
13년 전 조회 2,988
13년 전 조회 5,777
13년 전 조회 3,908
13년 전 조회 4,091
13년 전 조회 2,441
13년 전 조회 9,759
13년 전 조회 4,611
13년 전 조회 2,665
13년 전 조회 2,533
13년 전 조회 3,914
13년 전 조회 6,645
13년 전 조회 4,648
13년 전 조회 2,569
13년 전 조회 1.5만
13년 전 조회 2,447
13년 전 조회 1,873
13년 전 조회 5,142
13년 전 조회 2,635
13년 전 조회 1.1만
13년 전 조회 2,047
13년 전 조회 2,451
13년 전 조회 4,500
13년 전 조회 2,101
13년 전 조회 3,001
13년 전 조회 4,929
13년 전 조회 2,316
13년 전 조회 2,212
13년 전 조회 6,582
13년 전 조회 2,673
13년 전 조회 2,006
13년 전 조회 3,757
13년 전 조회 3,773
13년 전 조회 2,727
13년 전 조회 4,178
13년 전 조회 7,838
13년 전 조회 3,412
13년 전 조회 2,005
13년 전 조회 3,162
13년 전 조회 3,097
13년 전 조회 3,894
13년 전 조회 1,856
13년 전 조회 2,963
13년 전 조회 1,995
13년 전 조회 3,038
13년 전 조회 3,950
13년 전 조회 2,431
13년 전 조회 5,137
13년 전 조회 1.1만
13년 전 조회 2,400
13년 전 조회 3,753
13년 전 조회 3,370