|
 |
|
ช่วยทีครับ ต้องการตรวจสอบเลขบัตรประชาชน 13 หลัก แล้วแสดงสถานะ 1 หรือ 0 ทันที |
|
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function num_key(evt){
var iKeyCode;
if(window.event){ // IE
iKeyCode = evt.keyCode
}
else if(evt.which){ // Netscape/Firefox/Opera
iKeyCode = evt.which
}
if ((iKeyCode >= 48 && iKeyCode <= 57) || iKeyCode == 8 || iKeyCode == 46){ // 8 Backapace , 46 Delete
return true;
}
else{
return false;
}
}
function checkID(id) {
if (id.length == 13){
for(i=0, sum=0; i < 12; i++){
sum += parseFloat(id.charAt(i))*(13-i);
}
if ((11-sum%11)%10!=parseFloat(id.charAt(12))){
alert('รหัสบัตรประชาชนไม่ถูกต้อง');
document.getElementById("sp_result").innerHTML = "<img src='/robust/cms/images/avatar.jpg'>0";
}
else {
document.getElementById("sp_result").innerHTML = "<img src='/robust/cms/images/avatar.jpg'>1";
}
}
}
function fncSubmit(){
if(document.getElementById("sp_result").innerHTML == "" || document.getElementById("sp_result").innerHTML.indexOf("0") !=-1){
alert("นั่นไง...ว่าแล้ว เรารู้นะ...ว่าคุณมั่ว\nกรุณากรอกเลขบัตรจริงๆ เถอะครับ!");
document.getElementById("id_card_txt").focus();
}
else{
if(confirm("คุณต้องการที่จะบันทึกข้อมูล ใช่หรือไม่ ?")){
document.f.target = "_top";
document.f.method = "post";
document.f.action = "update.php";
document.f.submit();
}
}
}
</script>
<BODY>
<form name="f">
<table border="1">
<tr>
<td width="100">
<input type="text" name="id_card_txt" id="id_card_txt" maxlength="13" onKeyPress="return num_key(event);" onkeyUp="checkID(this.value);">
</td>
<td width="100"><span id="sp_result"></span></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="Submit" value="ตรวจสอบ!" onClick="fncSubmit();">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
|
 |
 |
 |
 |
Date :
2013-06-29 15:15:36 |
By :
thep |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2016-07-29 08:34:39 |
By :
ongpongpaw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|