if (isset($_POST['submit'])) { if (empty($_POST['c_firstname']) || empty($_POST['c_lastname']) || empty($_POST['c_idcard']) || empty($_POST['email']) || empty($_POST['mobile'])) { $error = "กรุณากรอกข้อมูลให้ครบถ้วนครับ";
if(strlen($_POST['c_idcard'])<13){ echo 'ห้ามต่ำกว่า 13 หลัก'; }
<script> function ChkID() { var IDlen = parseInt(document.getElementById('id').value.length); if(IDlen<12){ alert('Please input 13 digits ID card'); }else{ alert('Successed'); } } </script> ID : <input type="text" name="id" id="id"> <input type="button" name="submit" id="submit" onclick="ChkID()" value="Click!">
<script language="JavaScript" type="text/JavaScript"> 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; } function checkvalue(){ if(document.formRegister.card.value == "" ){ alert('กรุณากรอกเลขบัตรประจำตัวประชาชน'); document.formRegister.card.focus(); return false; } if(document.formRegister.card.value.length <13){ alert('กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ 13 หลัก'); document.formRegister.card.focus(); return false; } if(document.formRegister.card.value.length >13){ alert('เลขบัตรประจำตัวประชาชนเกิน กรุณากรอกเลขบัตรประจำตัวประชาชนเพียง 13 หลักเท่านั้น'); document.formRegister.card.focus(); return false; } if(isNaN(document.formRegister.card.value)){ alert('กรุณากรอกเลขบัตรประจำตัวประชาชนเป็นตัวเลขเท่านั้น'); document.formRegister.card.focus(); return false; } if(!checkID(document.formRegister.card.value)){ alert('รหัสบัตรประจำตัวประชาชนไม่ถูกต้อง'); document.formRegister.card.focus(); return false; } document.getElementById("formRegister").submit(); } </script> <form id="formRegister" name="formRegister" method="post" action="xxxxx.php"> <tr> <td width="40%"><p class=th_headingboldmedium>เลขบัตรประจำตัวประชาชน :</p></td> <td width="55%" ><input name="card" type="text" id="card" value="" size="50" maxlength="13"></td> <td valign=top width="3%"> </td> </tr> <input name="xxx" type="button" onClick="checkvalue()" class="style54" value=" บันทึก " style='background-color:#9999FF; color:#FF0000;'> </form>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง