|
 |
|
ช่วยดูโค้ด หน่อยคับ หน้า from regis คือ อยากจะให้เช็ครหัสบ้ตรประชาชน ทุกครั้งที่กรอก อะคับ แต่ที่ ลองทำมันได้ แค่ครั้งแรก |
|
 |
|
|
 |
 |
|
ลองเปลี่ยน OnChange เป็น OnKeyUp ดูครับ
<input name="mem_idcard" type="text" id="mem_idcard" size="30" onchange="checkForm();return false;"/>
<input name="mem_idcard" type="text" id="mem_idcard" size="30" onKeyUp="checkForm();return false;"/>
|
 |
 |
 |
 |
Date :
2014-02-21 11:16:36 |
By :
mitchiketta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไปเล่นดู ขำขำ
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javaScript">
//-- ใช้คีย์บอร์ดได้-กรอกได้เฉพาะตัวเลข : เลขบัตรประชาชน llllll สามาร
function Numbers(e){
var keynum;
var keychar;
var numcheck;
if(window.event) {// IE
keynum = e.keyCode;844
}
else if(e.which) {// Netscape/Firefox/Opera
keynum = e.which;
}
if(keynum == 13 || keynum == 8 || typeof(keynum) == "undefined"){
return true;
}
keychar= String.fromCharCode(keynum);
numcheck = /^[0-9]$/;
return numcheck.test(keychar);
}
function keyup(obj,e){
var keynum;
var keychar;
var id = '';
if(window.event) {// IE
keynum = e.keyCode;
}
else if(e.which) {// Netscape/Firefox/Opera
keynum = e.which;
}
keychar= String.fromCharCode(keynum);
var tagInput = document.getElementsByTagName('input');
for(i=0;i<=tagInput.length;i++){
if(tagInput[i] == obj){
var prevObj = tagInput[i-1];
var nextObj = tagInput[i+1];
break;
}
}
if(obj.value.length == 0 && keynum == 8) prevObj.focus();
if(obj.value.length == obj.getAttribute('maxlength')){
for(i=0;i<=tagInput.length;i++){
if(tagInput[i].id.substring(0,5) == 'txtID'){
if(tagInput[i].value.length == tagInput[i].getAttribute('maxlength')){
id += tagInput[i].value;
if(tagInput[i].id == 'txtID5') break;
}
else{
tagInput[i].focus();
return;
}
}
}
//เก็บค่ารวมลง Hidden Inpit ตอนส่งไปอีกเพจ
document.getElementById('id_card_txt').value = (document.getElementById('txtID1').value)+(document.getElementById('txtID2').value)+(document.getElementById('txtID3').value)+(document.getElementById('txtID4').value)+(document.getElementById('txtID5').value);
//ทำการตรวจสอบเลขบัตรประชาชน
if(checkID(id)){
//ถูกต้อง
document.getElementById("sp_result").innerHTML = "ถูกต้อง";
document.getElementById("txtID1").focus();
}else{
//ไม่ถูกต้อง
document.getElementById("sp_result").innerHTML = "<font color='red'> * เลขบัตรประชาชนไม่ถูกต้อง </font>";
txtID1.focus();
}
}
}
//--ฟังก์ชั่นที่ใช้ในการตรวจสอบเลขบัตรประชาชน
function checkID(id){
if(id.length != 13) return false;
for(i=0, sum=0; i < 12; i++)
sum += parseFloat(id.charAt(i))*(13-i);
if((11-sum%11)%10!=parseFloat(id.charAt(12)))
return false;
return true;
}
</script>
</head>
<body class="page-index">
<div id="wrapper">
<div class="step">
<h3 class="title"></h3>
<div>
<form id="regis" name="regis" action="confirm.php" method="post" onsubmit="JavaScript:return send_data();">
<div class="form-item">
<label for="id_card">เลขบัตรประชาชน:</label>
<input type="text" name="txtID1" id="txtID1" style="width:12px" align="left" maxlength=1 onkeyup="keyup(this,event)" onkeypress="return Numbers(event)" /> -
<input type="text" name="txtID2" id="txtID2" style="width:35px" align="left" maxlength=4 onkeyup="keyup(this,event)" onkeypress="return Numbers(event)" /> -
<input type="text" name="txtID3" id="txtID3" style="width:40px" align="left" maxlength=5 onkeyup="keyup(this,event)" onkeypress="return Numbers(event)" /> -
<input type="text" name="txtID4" id="txtID4" style="width:20px" align="left" maxlength=2 onkeyup="keyup(this,event)" onkeypress="return Numbers(event)" /> -
<input type="text" name="txtID5" id="txtID5" style="width:12px" align="left" maxlength=1 onkeyup="keyup(this,event)" onkeypress="return Numbers(event)" />
<span id="sp_result"></span>
<br />
<input name="id_card_txt" type="text" id="id_card_txt" maxlength=13 readonly="readonly" />
<span id="f"></span>
</div>
<!-- ปิดซ่อนฟอร์ม <div id="search_1" style="display:none;"> --><br>
<br>
<div class="form-item" id="b" style="display:none;"><input type="submit" id="button1" name="button1" value=" ลงทะเบียน " style="background-color:#039; font-size:18px; color:#FFF; border-style:solid solid solid solid; border-color:#CF9;" /></div>
<!-- ของเลขบัตร </div> -->
</form>
</div> <!-- /#login-form -->
</div><!-- /#wrapper -->
</div>
</body>
|
 |
 |
 |
 |
Date :
2014-02-21 11:27:53 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|