전화번호 숫자 정규식이요
본문
제가 쓰고있는 게시판 write.skin.php 파일입니다.
잘 쓰고 있는데 전화번호가 좀 말썽이네요..
전화번호 입력시 자꾸 한두자만 입력 허용되서 문제 입니다..
저는 전화번호 입력시
첫번째입력칸 2~3자만 허용 두번째입력칸 3~4자만허용 세번째입력칸 4자만 허용
이렇게 하고 싶은데 정규식을 잘몰라서요
부탁 드려요~ㅜㅜ
<meta name="generator" content="Namo WebEditor(Trial)">
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if ($is_dhtml_editor) {
include_once("$g4[path]/lib/cheditor4.lib.php");
echo "<script src='$g4[cheditor4_path]/cheditor.js'></script>";
echo cheditor1('wr_content', '100%', '250');
}
//연락처
$wr10 = explode("|",$write[wr_10]);
$tel1 = $wr10[0];
$tel2 = $wr10[1];
$tel3 = $wr10[2];
?>
<script type="text/javascript" language="javascript">
function OnlyNumber(obj, chkint){
if(isNaN(obj.value)){
alert("숫자만 입력 가능합니다.");
obj.value="";
obj.focus();
return false;
}
if(obj.value > Number(chkint)) {
alert(chkint+"이하의 숫자만 가능합니다.");
obj.value="";
obj.focus();
return false;
}
}
function chk(){
var req = document.form.req.checked;
var num = 0;
if(req == true){
num = 1;
}
if(num==1){
document.form.submit();
window.close();
}else{
alert("개인정보 수집 및 이용에 동의하셔야 합니다.");
}
}
function nochk(){
alert("비동의시 상담신청이 제한됩니다.");
}
</script>
<script type="text/javascript">
// 글자수 제한
var char_min = parseInt(<?=$write_min?>); // 최소
var char_max = parseInt(<?=$write_max?>); // 최대
</script>
<script>function rule() { url = "http://haemiin.com/bbs4/skin/board/basic_order/rule.php" ; window.open(url,'','toolbar=no,menubar=no,location=no,directions=no, scrollbars=yes,status=yes,width=700,height=400'); } </script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
<form name="fwrite" method="post" onsubmit="return fwrite_submit(this);" enctype="multipart/form-data" style="margin:0px;">
<input type=hidden name=null>
<input type=hidden name=w value="<?=$w?>">
<input type=hidden name=bo_table value="<?=$bo_table?>">
<input type=hidden name=wr_id value="<?=$wr_id?>">
<input type=hidden name=sca value="<?=$sca?>">
<input type=hidden name=sfl value="<?=$sfl?>">
<input type=hidden name=stx value="<?=$stx?>">
<input type=hidden name=spt value="<?=$spt?>">
<input type=hidden name=sst value="<?=$sst?>">
<input type=hidden name=sod value="<?=$sod?>">
<input type=hidden name=page value="<?=$page?>">
<style>
.Table2 {width:100%; margin:0 auto; border:0px solid #444; border-collapse:collapse;}
.Table2 th {width:30%; border:0px solid #444; text-align:right; font-size:12px; padding:8px 20px; color:#ddd;}
.Table2 td {border:0px solid #444; padding:8px 10px;font-size:12px;}
.Table2 input,textarea {background-color:#222; border:0px; color:#ddd;}
.inputD{height:25px;}
.inputtit {width:500px;}
.Tbtn {margin-bottom:20px;font-size:12px;}
</style>
<table class="Table2">
<tr>
<th width="20%">제목</th>
<td><input class="inputtit" name=wr_subject id="wr_subject" required itemname="신청제목" value="<?=$subject?>"></td>
</tr>
<tr>
<th>이름</th>
<td><input class="inputD" maxlength=30 size=20 name=wr_name required itemname="이름" value="<?=$write[wr_name]?>"></td>
</tr>
<tr>
<th>연락처</th>
<td><input class="inputD" name='hp1' value='<?=$hp1?>' type='text' size='6' maxlength='4' onkeyup="OnlyNumber(this);" itemname='연락처 두번째자리' required>
<input class="inputD" name='hp2' value='<?=$hp2?>' type='text' size='4' maxlength='4' onkeyup="OnlyNumber(this);" itemname='연락처 두번째자리' required>
<input class="inputD" name='hp3' value='<?=$hp3?>' type='text' size='4' maxlength='4' onkeyup="OnlyNumber(this);" itemname='연락처 세번째자리' required>
* 전화번호를 정확히 입력해주세요</td>
</tr>
<tr>
<th>내용</th>
<td><textarea id="wr_content" style="width:500;height:250px;" name="wr_content" rows=5
<? if ($write_min || $write_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?}?>><?=$content?></textarea>
<? if ($write_min || $write_max) { ?><script type="text/javascript"> check_byte('wr_content', 'char_count'); </script><?}?></td>
</tr>
<tr>
<th></th>
<td>
<div class="Tbtn" >개인정보수집,제공동의서 <a href="javascript:rule();" style="color:#ff6600;">[자세히보기]</a>
<label for="r2_1"><input type="radio" id="r2_1" name=wr_1 value="1" <?if($write[wr_1]=="1")echo"checked";?>CHECKED ="on"> 동의합니다. </label>
<label for="r2_2"><input type="radio" id="r2_2" name=wr_1 value="0"<?if($write[wr_1]=="0")echo"checked";?> onclick="nochk()"> 비동의합니다. </label>
</div>
<input type=image id="btn_submit" src="<?=$board_skin_path?>/img/bt_subit.gif" border=0 accesskey='s'>
</td>
</tr>
</table>
</form>
<script type="text/javascript" src="<?="$g4[path]/js/jquery.kcaptcha.js"?>"></script>
<script type="text/javascript">
with (document.fwrite)
{
if (typeof(wr_subject) != "undefined")
wr_subject.focus();
else if (typeof(wr_name) != "undefined")
wr_name.focus();
else if (typeof(wr_1) != "undefined")
wr_1.focus();
if (typeof(ca_name) != "undefined")
if (w.value == "u")
ca_name.value = "<?=$write[ca_name]?>";
}
function html_auto_br(obj)
{
if (obj.checked) {
result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
if (result)
obj.value = "html2";
else
obj.value = "html1";
}
else
obj.value = "";
}
function fwrite_submit(f)
{
<?
if ($g4[https_url])
echo "f.action = '$g4[https_url]/$g4[bbs]/write_update.php';";
else
echo "f.action = './write_update.php';";
?>
/*
var s = "";
if (s = word_filter_check(f.wr_subject.value)) {
alert("제목에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
if (s = word_filter_check(f.wr_content.value)) {
alert("내용에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
*/
if (document.getElementById('char_count')) {
if (char_min > 0 || char_max > 0) {
var cnt = parseInt(document.getElementById('char_count').innerHTML);
if (char_min > 0 && char_min > cnt) {
alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
}
else if (char_max > 0 && char_max < cnt) {
alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
}
<?
if ($is_dhtml_editor) echo cheditor3('wr_content');
?>
var subject = "";
var content = "";
$.ajax({
url: "<?=$board_skin_path?>/ajax.filter.php",
type: "POST",
data: {
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
content = data.content;
}
});
if (content) {
alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
if (typeof(ed_wr_content) != "undefined")
ed_wr_content.returnFalse();
else
f.wr_content.focus();
return false;
}
if (!check_kcaptcha(f.wr_key)) {
return false;
}
document.getElementById('btn_submit').disabled = true;
document.getElementById('btn_cancel').disabled = true;
return true;
}
</script>
<script type="text/javascript" src="<?="$g4[path]/js/board.js"?>"></script>
<script type="text/javascript"> window.onload=function() { drawFont(); } </script>
답변을 작성하시기 전에 로그인 해주세요.