

// ตรวจสอบวัน
function dmy(str_day,str_month,str_year)
	{
	f = document.all;
    var cday=eval("f."+str_day+".value");
	var cmonth=eval("f."+str_month+".value");
	var cyear=eval("f."+str_year+".value");
	if((cmonth == '4')||(cmonth == '6')||(cmonth == '9')||(cmonth == '11'))
	{
		if(cday > 30)
		{
		alert ('เกิดการผิดพลาด  ( เดือนนี้มี 30 วัน )');
		eval("f."+str_day+".value = 30 ");
		eval("f."+str_day+".focus");
		}
	}
	else if(cmonth =='2')
		{
		var nyear = eval((cyear - 543)%4);
		if( nyear > 0 && cday > 28)
			{
		//	alert(nyear);
			alert('เกิดการผิดพลาด  ( เดือนนี้มี 28 วัน )');
			eval("f."+str_day+".value = 28 ");
			eval("f."+str_day+".focus");
			}
		else if( nyear == 0 && cday > 29)
			{
			//alert(nyear);
			alert(' เกิดการผิดพลาด  ( เดือนนี้มี 29 วัน )');
			eval("f."+str_day+".value = 29 ");
			eval("f."+str_day+".focus");
			}
		}
	}
	

// ตรวจสอบ ชื่อ user name

function checkusername(ch){
	var len, digit;
	if(ch == " "){ 
      		 len=0;
    	}else{
    		 len = ch.length;
	}
	for(var i=0 ; i<len ; i++)
	{
		digit = ch.charAt(i)
		if( (digit >= "a" && digit <= "z")  || (digit >="0" && digit <="9") || (digit >="A" && digit <="Z") || (digit =="_")){
			;	
		}else{
			return false;					
		}		
	}		
	return true;
}	

// ตรวจสอบ เฉพาะตัวเลข
function check_number(ch){
	var len, digit;
	if(ch == " "){ 
		return false;
      		 len=0;
    	}else{
    		 len = ch.length;
	}
	for(var i=0 ; i<len ; i++)
	{
		digit = ch.charAt(i)
		if(digit >="0" && digit <="9"){
			;	
		}else{
			return false;					
		}		
	}		
	return true;
}

// ตรวจสอบอีเมล
			  function check_email(e) {
			ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
			for(i=0; i < e.length ;i++){
			if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
			}	
			} 
			if (document.images) {
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two)) {
			return (-1);		
			} 
			}
			}