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,437
13년 전 조회 2,236
13년 전 조회 4,046
13년 전 조회 1만
13년 전 조회 2,617
13년 전 조회 2,568
13년 전 조회 3,010
13년 전 조회 2,459
13년 전 조회 2,620
13년 전 조회 4,895
13년 전 조회 2,847
13년 전 조회 3,493
13년 전 조회 2,485
13년 전 조회 2,660
13년 전 조회 4,397
13년 전 조회 2,236
13년 전 조회 2,731
13년 전 조회 3,046
13년 전 조회 3,482
13년 전 조회 3,585
13년 전 조회 4,041
13년 전 조회 2,491
13년 전 조회 2,503
13년 전 조회 5,896
13년 전 조회 2,945
13년 전 조회 3,113
13년 전 조회 6,984
13년 전 조회 4,681
13년 전 조회 3,622
13년 전 조회 2,793
13년 전 조회 4,972
13년 전 조회 3,982
13년 전 조회 3,660
13년 전 조회 3,345
13년 전 조회 3,020
13년 전 조회 2,988
13년 전 조회 2,757
13년 전 조회 3,875
13년 전 조회 3,190
13년 전 조회 2,814
13년 전 조회 3,894
13년 전 조회 3,100
13년 전 조회 3,704
13년 전 조회 4,921
13년 전 조회 2,679
13년 전 조회 3,642
13년 전 조회 2,482
13년 전 조회 2,982
13년 전 조회 3,592
13년 전 조회 3,239
13년 전 조회 6,036
13년 전 조회 4,150
13년 전 조회 4,315
13년 전 조회 2,711
13년 전 조회 1만
13년 전 조회 4,843
13년 전 조회 2,915
13년 전 조회 2,787
13년 전 조회 4,174
13년 전 조회 6,906
13년 전 조회 4,902
13년 전 조회 2,820
13년 전 조회 1.5만
13년 전 조회 2,698
13년 전 조회 2,130
13년 전 조회 5,242
13년 전 조회 2,718
13년 전 조회 1.1만
13년 전 조회 2,306
13년 전 조회 2,558
13년 전 조회 4,749
13년 전 조회 2,357
13년 전 조회 3,267
13년 전 조회 5,177
13년 전 조회 2,556
13년 전 조회 2,462
13년 전 조회 6,842
13년 전 조회 2,938
13년 전 조회 2,253
13년 전 조회 3,998
13년 전 조회 4,029
13년 전 조회 3,003
13년 전 조회 4,439
13년 전 조회 8,099
13년 전 조회 3,664
13년 전 조회 2,278
13년 전 조회 3,404
13년 전 조회 3,361
13년 전 조회 4,123
13년 전 조회 2,128
13년 전 조회 3,225
13년 전 조회 2,092
13년 전 조회 3,287
13년 전 조회 4,196
13년 전 조회 2,541
13년 전 조회 5,411
13년 전 조회 1.2만
13년 전 조회 2,653
13년 전 조회 4,036
13년 전 조회 3,635