function isNotBlank(str, name) {
    //var str 	= obj.value ; // value to be 'tested'
    //var name 	= obj.name  ; // name of the field
    var errMsg	= "Please enter your " +name + ".\nRequired entry !"
    if (str == "" || str == null) {
        alert(errMsg) ; // tell the user what is wrong
        //obj.focus()   ; // focus on the field with the problem
        //obj.select()  ; // select the contents of the field with the problem
        return false  ; // tell wrap around function that this value fails
    }
    return true ; // tell wrap around function that this value passes
}
function isValidEmail (str, name){
    //var str 	= obj.value ; // value to be 'tested'
    //var name 	= obj.name  ; // name of the field
    var errMsg	= "Please enter your valid email address."
    	  errMsg +="\nfor " + name + ". (Required entry)" ;
    	  errMsg +="\nYou entered \"" + str +"\"." ;

   var newString = str.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.biz)|(\..{2,2}))$)\b/gi);
   if (!newString){
   		alert(errMsg) ; // tell the user what is wrong
    		//obj.focus() ; // focus on the field with the problem
		//obj.select()  ; // select the contents of the field with the problem
		return false  ; // tell wrap around function that this value fails
   }
   for (var i=0; i<str.length;i++){
		var ch=str.charAt(i);
        if (ch == "[" || ch == "]" || ch=="(" || ch==")" || ch=="'" || ch==":" || ch==">" || ch==","){
        	alert("Email not allow (,)[']:>; Chapters");
			//obj.focus();
			//obj.select();
			return false;
		}
   }
    return true; // tell wrap around function that this value passes
}

function isEqual(obj1,obj2){
var str1 = obj1.value;
var str2 = obj2.value;
	if(str1!=str2){
		alert("Entered passwords did not match !");
		obj2.focus();
		obj2.select();
		return false;
	}
	return true;
}

function isSixLength(obj){
var str=obj.value;
var name=obj.name;
	if(str.length<5){
		alert(name + " at least 5 characters long !");
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}

function isNum (obj){
	var num     = obj.value;
	var name    = obj.name;
	var errMsg  = "Please enter your " + name + ".\nRequired entry !";
	if (num==""){
		alert(errMsg);
		obj.focus();
		obj.select();
		return false;
	}
	for (i=0; i<num.length; i++){
		if(num.charAt(i) <"0"){
			alert( name + " Must be Number !");
			obj.focus();
			obj.select();
			return false;
		}
		if(num.charAt(i) >"9"){
			alert(name + " Must be Number !");
			obj.focus();
			obj.select();
			return false;
		}
	}
	return true ;
}

function isNotExpiry(obj1,obj2){
	now = new Date;

	if (obj2.value < now.getYear() )
	{
		alert("Credit Card year Expired!");
			//obj2.focus();
			//obj2.select();
		return false;
	}
	else if (obj2.value == now.getYear() )
	{
		if (obj1.value < now.getMonth()+1 )
			{
			alert("Credit Card month Expired!");
			//obj1.focus();
			//obj1.select();
			return false;
		}
		return true;
		
	}
	
	return true;

}

function isValidPhone(obj){

var re=/\(?\d{3}[\)\-\/\.\s]?\d{3}([-\/\.\s])\d{4}/

var str = obj.value;

//RegExp.input=str;

var name=obj.name;

var errMsg ="please enter your Telephone Number."

	errMsg+="\nin "+ name + ". (Required entry)";

	errMsg+="\nYou entered \"" + str + "\".";

	errMsg+="\ntry a pattern like (999)999-9999,\n999.999.9999 or 999-999-9999"; 

	if (!re.test(str)){

		alert(errMsg);

		obj.focus() ; // focus on the field with the problem

		obj.select();

		return false;

	}

	return true;

}

function isValidPhoneNum(obj){

var re=/\(?\d{3}[\)\-\/\.\s]?\d{3}([-\/\.\s])\d{4}/

var str = obj.value;

//RegExp.input=str;

var name=obj.name;

var errMsg ="please enter your Telephone Number."

	errMsg+="\nin "+ name + ". (Required entry)";

	errMsg+="\nYou entered \"" + str + "\".";

	errMsg+="\ntry a pattern like (999)999-9999,\n999.999.9999 or 999-999-9999"; 

if (str!=""){
	if (!re.test(str)){

		alert(errMsg);

		obj.focus() ; // focus on the field with the problem

		obj.select();

		return false;

	}
}
	return true;

}

function isValidPostal(obj){
var str = obj.value;
var name = obj.name;
var upStr = str.toUpperCase();
var errMsg = "Please input your valid Postal Code." 
	errMsg +="\nfor " + name + ". (Required entry)";
	errMsg +="\nYou entered \""  + upStr + "\".";
	errMsg +="\nTry Letter Didit Letter Space Digit Letter Digit";
	errMsg +="\ne.g. V1A 2K9 (Canadian Example)";
	errMsg +="\n or 5 digits or 9 digits (USA Version)";

obj.value=upStr;
newString =upStr.match((/(\b(^[A-Z]\d[A-Z]\s\d[A-Z]\d))|(\d(5))|(\d(9))/g));
if (!newString)
{
	alert(errMsg);
	obj.focus();
	obj.select();
	return false;
}
return true;
}
