μλ νμΈμ κ°λ°μ½κ²νμκ³° μ λλ€.
λ μ¨κ° λ§μ΄ μ°μ€μΆ©νλ€μ μ΄μ λ λ²κ°κΉμ§ μΉλλ°... ν λ무 μ°μ°ν ν루μμ γ γ
νμκ°μ μ΄λ λ°λ‘ νΈλν° λ²νΈλ₯Ό μ λ ₯λ°μμΌ ν λ λ§μ΄ μ¬μ©λλ λ°©λ²μ λν΄ κ³΅μ λλ¦¬κ³ μ ν©λλ€.
νΈλν° λ²νΈ κ²μ¦κ³Ό μ κ·μ
μ°μ 010/1234/5678 κ΄λ ¨ν΄μ κ°κ° λ°λ‘ μ λ ₯λ°μ νλλ‘ ν©μΉλ 건λ°μ γ γ
μ΄λ κ²μ γ γ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("button").on('click', function(){
alert($("#phone1").val());
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3'>
<input type="text" name="phone2" id="phone2" maxlength='4'>
<input type="text" name="phone3" id="phone3" maxlength='4'>
<button>μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
μ΄λ κ² νλμ© μΆλ ₯νλ©΄μ μ λ ν°λ₯Ό μ‘μμ€λλ€.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("button").on('click', function(){
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
//νμκ° μ²΄ν¬
if(!phone1 || !phone2 || !phone3)
{
alert("νμκ° λλ½!");
return false;
}
var phone_number = phone1 + phone2 + phone3;
$("#phone_number").val(phone_number);
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3'>
<input type="text" name="phone2" id="phone2" maxlength='4'>
<input type="text" name="phone3" id="phone3" maxlength='4'>
<button>μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
νμ κ° μ²΄ν¬λ ν΄μ€¬μ΅λλ€.
κ·Έλ°λ° μ νλ²νΈ κ°μ κ²½μ°μ - (νμ΄ν) μ΄ λΆμ΄μΌ νλ€λ©΄.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("button").on('click', function(){
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
//νμκ° μ²΄ν¬
if(!phone1 || !phone2 || !phone3)
{
alert("νμκ° λλ½!");
return false;
}
var phone_number = phone1 + "-" + phone2 + "-" + phone3;
$("#phone_number").val(phone_number);
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3'>
<input type="text" name="phone2" id="phone2" maxlength='4'>
<input type="text" name="phone3" id="phone3" maxlength='4'>
<button>μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
μ΄λ° μμΌλ‘ ν΄μ£Όλ©΄ λ©λλ€.
μ λ μ¬κΈ°μ input boxμ μ«μλ§ μ λ ₯λ°κ²λ νκ² μ΅λλ€.
μ΄ λ°©λ²λ μ’μ§λ§ 볡λΆμ μ·¨μ½ν©λλ€.
κ°λ³κ² 보μ¬λ리μλ©΄
μ΄λ κ² onkeyupμ΄κΈ°μ ν€μ μ μ ν μνλ‘ μ λ ₯νκ² λλ©΄ λ°κ² λμ£
μ λ μ΄λ° λΆλΆλ€μ΄ μ«μ΄μ λ€λ₯Έ λ°©μμΌλ‘ νλ €κ³ ν©λλ€.
oninputμ μΈ κ²λλ€
oninputμ΄λ?
oninput
oninput μ΄λ²€νΈλ μμκ° μ¬μ©μ μ λ ₯μ λ°μ λ λ°μν©λλ€.
μ΄ μ΄λ²€νΈλ <input> λλ <textarea> μμμ κ°μ΄ λ³κ²½λ λ λ°μν©λλ€.
νλ§λλ‘ μ λ ₯λ°μ μ¦μ onkeydownκ³Ό onkeyupμ¬μ΄?λΌκ³ μκ°νμλ©΄ λ©λλ€.
κ°μ΄ λ€μ΄μ¬ λλΌκ³ 보μλ©΄ λ©λλ€.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("button").on('click', function(){
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
//νμκ° μ²΄ν¬
if(!phone1 || !phone2 || !phone3)
{
alert("νμκ° λλ½!");
return false;
}
var phone_number = phone1 + "-" + phone2 + "-" + phone3;
$("#phone_number").val(phone_number);
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<input type="text" name="phone2" id="phone2" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<input type="text" name="phone3" id="phone3" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<button>μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
κ·Έλ¦¬κ³ μ λ 010μ μ λ ₯νμ λ λ€μ inputboxλ‘ ν¬μ»€μ± λκ² μ²λ¦¬ν΄λ³΄λ €κ³ ν©λλ€. νΈνλκΉμ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("button").on('click', function(){
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
//νμκ° μ²΄ν¬
if(!phone1 || !phone2 || !phone3)
{
alert("νμκ° λλ½!");
return false;
}
var phone_number = phone1 + "-" + phone2 + "-" + phone3;
$("#phone_number").val(phone_number);
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" onkeyup="if(this.value.length == 3) $('#phone2').focus();">
<input type="text" name="phone2" id="phone2" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" onkeyup="if(this.value.length == 4) $('#phone3').focus();">
<input type="text" name="phone3" id="phone3" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<button>μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
ν¬μ»€μ± μ²λ¦¬ νμ λλ€.
κ°λ¨ν 보μ¬λ리μλ©΄
μ²μμ 3κΈμ μ λ ₯νκ³ λ€μ μΈν λ°μ€λ‘ λ€μμ 4κΈμ μ λ ₯ μ μλμΌλ‘ λμ΄κ°κ² λ©λλ€.
μ€κ°μ κ² μκ°
λ³΄κ³ κ³μλ μ¬λ¬λΆλ€λ νλ² ν΄λ³΄μΈμ γ γ
κ·Έλ€μμ ν΄μΌ νλ κ²μ μ΄κ² μ§μ§ μ νλ²νΈκ° λ§λκ°? μλκ°? νμΈμ λλ€.
μλ₯Ό λ€μ΄ 089λ‘ μμνλ λ²νΈλ μμΌλκΉμ
μ°λ¦¬λλΌ νΈλν° λ²νΈλ 010,016,011,017,018,019 μ λκ° μκ² μ΅λλ€.
λ€ λ°λλ€κ³ νλ κ±° κ°μλ° νΉμλ.. νΉμλ ν΄μ κ²μ¦μ νκ² μ΅λλ€.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>easy-developmentbear</title>
<!-- μ μ΄μΏΌλ¦¬ -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(function(){
$("#submit").on('click', function(){
var phone1 = $("#phone1").val();
var phone2 = $("#phone2").val();
var phone3 = $("#phone3").val();
//νμκ° μ²΄ν¬
if(!phone1 || !phone2 || !phone3)
{
alert("νμκ° λλ½!");
return false;
}
//μ κ·μ
var regPhone = /^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})$/;
//λ²νΈ ν©μΉκΈ°
var phone_number = phone1 + "-" + phone2 + "-" + phone3;
//λ²νΈκ²μ¦
if(!regPhone.test(phone_number))
{
alert("μλͺ»λ λ²νΈμ
λλ€.");
return false;
}
$("#phone_number").val(phone_number);
});
});
</script>
</head>
<body>
<input type="text" name="phone1" id="phone1" maxlength='3' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" onkeyup="if(this.value.length == 3) $('#phone2').focus();">
<input type="text" name="phone2" id="phone2" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" onkeyup="if(this.value.length == 4) $('#phone3').focus();">
<input type="text" name="phone3" id="phone3" maxlength='4' oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
<button id="submit">μΆλ ₯</button><br><br>
<input type="text" name="phone_number" id="phone_number">
</body>
</html>
μ μ½λλ μ΅μ’ μ½λμ λλ€.
μ νλ²νΈκ° λ§λμ§ μλμ§ νμΈν΄λ³΄μλ©΄ λ©λλ€.
μ΄λ κ² νΈλν° λ²νΈ μ κ·μκ³Ό μ«μλ§ μ λ ₯λ°κ³ μλ ν¬μ»€μ± μ²λ¦¬κΉμ§ ν΄λ΄€λλ°μ γ γ
λ€μμ μκ° λλ©΄ μ΄λ©μΌλ ν΄λ΄μΌκ² μ΄μ μ¬λ°λ€μ μ κ·μ μμλμΌλ©΄ μμλμλ‘ μ’μ..γ γ
λ€μμ λ μ’μ μ λ³΄λ‘ μ°Ύμλ΅κ²μ γ γ λ€λ€ μ’μ ν루 보λ΄μΈμ!
λκΈ