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개

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

프로그램

태그 필터 (최대 3개) 전체 개발자 소스 기타 mysql 팁자료실 javascript php linux flash 정규표현식 jquery node.js mobile 웹서버 os 프로그램 강좌 썸네일 이미지관련 도로명주소 그누보드5 기획자 견적서 계약서 기획서 마케팅 제안서 seo 통계 서식 통계자료 퍼블리셔 html css 반응형 웹접근성 퍼블리싱 표준화 반응형웹 홈페이지기초 부트스트랩 angularjs 포럼 스크린리더 센스리더 개발자톡 개발자팁 퍼블리셔톡 퍼블리셔팁 기획자톡 기획자팁 프로그램강좌 퍼블리싱강좌
+
제목 글쓴이 날짜 조회
12년 전 조회 1,131
12년 전 조회 954
12년 전 조회 2,787
12년 전 조회 9,028
12년 전 조회 1,343
12년 전 조회 1,239
12년 전 조회 1,698
12년 전 조회 1,216
12년 전 조회 1,354
12년 전 조회 3,622
12년 전 조회 1,532
12년 전 조회 2,201
12년 전 조회 1,218
12년 전 조회 1,366
12년 전 조회 3,094
12년 전 조회 948
12년 전 조회 1,416
12년 전 조회 1,677
12년 전 조회 2,100
12년 전 조회 2,199
12년 전 조회 2,637
12년 전 조회 1,117
12년 전 조회 1,146
12년 전 조회 4,519
12년 전 조회 1,559
12년 전 조회 1,707
12년 전 조회 5,572
12년 전 조회 3,329
12년 전 조회 2,205
12년 전 조회 1,371
12년 전 조회 3,556
12년 전 조회 2,585
12년 전 조회 2,284
12년 전 조회 1,903
12년 전 조회 1,608
12년 전 조회 1,598
12년 전 조회 1,350
12년 전 조회 2,465
12년 전 조회 1,735
12년 전 조회 1,423
12년 전 조회 2,495
12년 전 조회 1,680
12년 전 조회 2,296
12년 전 조회 3,516
12년 전 조회 1,302
12년 전 조회 2,270
12년 전 조회 1,113
12년 전 조회 1,593
12년 전 조회 2,182
12년 전 조회 1,824
12년 전 조회 4,628
12년 전 조회 2,728
12년 전 조회 2,904
12년 전 조회 1,292
12년 전 조회 8,597
12년 전 조회 3,400
12년 전 조회 1,496
12년 전 조회 1,348
12년 전 조회 2,750
12년 전 조회 5,427
12년 전 조회 3,474
12년 전 조회 1,400
12년 전 조회 1.4만
12년 전 조회 1,263
12년 전 조회 674
12년 전 조회 3,995
12년 전 조회 1,518
12년 전 조회 9,407
12년 전 조회 843
12년 전 조회 1,305
12년 전 조회 3,276
12년 전 조회 910
12년 전 조회 1,823
12년 전 조회 3,724
12년 전 조회 1,135
12년 전 조회 1,019
12년 전 조회 5,368
12년 전 조회 1,499
12년 전 조회 818
12년 전 조회 2,743
12년 전 조회 2,550
12년 전 조회 1,569
12년 전 조회 2,997
12년 전 조회 6,607
12년 전 조회 2,204
12년 전 조회 799
12년 전 조회 1,964
12년 전 조회 1,913
12년 전 조회 2,672
12년 전 조회 665
12년 전 조회 1,749
12년 전 조회 833
12년 전 조회 1,829
12년 전 조회 2,749
12년 전 조회 1,303
12년 전 조회 3,937
12년 전 조회 1만
12년 전 조회 1,171
12년 전 조회 2,507
12년 전 조회 2,180
🐛 버그신고