// JavaScript Document
function check() {
if(document.checkForm.name.value=="") {
alert("กรุณากรอกชื่อ-นามสกุลด้วยค่ะ") ;
document.checkForm.name.focus() ;
return false ;
}
else if(!check_thai(document.checkForm.com_name.value) || document.checkForm.com_name.value == "" ) {
alert('กรุณากรอกชื่อบริษัทเป็นภาษาอังกฤษหรือตัวเลขเท่านั้น');
document.checkForm.com_name.focus() ;
return false ;
} 
else if(document.checkForm.com_nameth.value==""){
alert("กรุณากรอกชื่อบริษัทเป็นภาษาไทยด้วยค่ะ") ;
document.checkForm.com_nameth.focus() ;
return false ;
}
else if(document.checkForm.tel.value==""){
alert("กรุณากรอกเบอร์โทรศัพท์บริษัทด้วยค่ะ") ;
document.checkForm.tel.focus() ;
return false ;
}
else if(document.checkForm.mobile.value==""){
alert("กรุณากรอกเบอร์มือถือบริษัทด้วยค่ะ") ;
document.checkForm.mobile.focus() ;
return false ;
}
else if(document.checkForm.address.value=="") {
alert("กรุณากรอกที่อยู่ของบริษัทด้วยค่ะ") ;
document.checkForm.address.focus() ;
return false ;
}
else if(document.checkForm.province.selectedIndex==0) {
alert("กรุณาระบุจังหวัดที่ท่านอยู่ด้วยค่ะ") ;
document.checkForm.province.focus() ;
return false ;
}
else if(isNaN(document.checkForm.zipcode.value)) {
alert("รหัสไปรษณีย์ต้องเป็นตัวเลขค่ะ") ;
document.checkForm.zipcode.focus() ;
return false ;
}
else if(document.checkForm.user_name.value=="") {
alert("กรุณากรอกUsernameด้วยค่ะ") ;
document.checkForm.user_name.focus() ;
return false ;
}
else if(document.checkForm.pwd_name1.value=="") {
alert("กรุณากรอกPasswordด้วยค่ะ") ;
document.checkForm.pwd_name1.focus() ;
return false ;
}
else if(document.checkForm.email.value=="") {
alert("กรุณากรอกอีเมล์ด้วยนะค่ะ") ;
document.checkForm.email.focus() ;
return false ;
}
else if(checkForm.email.value.indexOf('@')==-1) {
alert("อีเมล์ของคุณไม่ถูกต้องค่ะ @ ") ;
document.checkForm.email.focus() ;
return false ;
}
else if(checkForm.email.value.indexOf('.')==-1) {
alert("อีเมล์ของคุณไม่ถูกต้องค่ะ . ") ;
document.checkForm.email.focus() ;
return false ;
}

else 
return true ;
}
function check_thai(com_name){
var len, digit;
if(com_name == " "){ 
len=0;
}else{
len = com_name.length;
}
for(var i=0 ; i<len ; i++)
{
digit = com_name.charAt(i)
if( ((digit >= "a" && digit <= "z") || (digit >="0" && digit <="9") || (digit >="A" && digit <="Z") || (digit ==" ") || (digit ==",") || (digit ==".") ||(digit =="-") || (digit =="_") )){
; 
}else{
return false; 
} 
} 
return true;
}

