// JavaScript Document

function checkForm(Obj){

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;

	
	if (isBlank(Obj.contact_name.value))

	 {alert("Please specify Name");Obj.contact_name.focus();return false;}

	if (isBlank(Obj.contact_number.value))

	 {alert("Please specify contact number");Obj.contact_number.focus();return false;}

	
	if (isBlank(Obj.contact_email.value))

	 {alert("Please specify email address");Obj.contact_email.focus();return false;}

	if (!filter.test(Obj.contact_email.value)) 

	 {alert('Incorrect email address.');Obj.contact_email.focus();return false;}


	return true;

}



function isBlank(str) {

	var len = str.length;

	var enter = 0;

     if(len == 0) {

     	return true;

     }

	  //Check if user only enter

	  for (i=0; i<len; i++) {

	  		if((str.charCodeAt(i) == 13)||(str.charCodeAt(i) == 10)||(str.charCodeAt(i) == 32)) {

	  			enter = 0;

	  		}

	  		else {

	  			return false;

	  		}

	  }	  

	  	return true;

}

function isValidDecimal(alphane) //Only two decimal point is allowed
{
   return /^[-+]?\d+(\.\d{1,2})?$/.test(alphane);
}

function isInteger(alphane)
{
	var test = false;
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if(hh > 47 && hh < 58)
		{ 
			test=true;
		}
		else
		{
			test=false;
			break;
		}
	}
	return test;
} 
function isValidPassword(name) //Password & secret answer (a-z A-Z _ 0-9 . - $ # !)
{
 //  alert(/^[a-zA-Z_0-9\.\-]+$/.test(name));
  return /^[a-zA-Z_#!0-9\.\-\$]+$/.test(name);
}
function isValidUserName(name) //UserName (a-z A-Z _ 0-9 . -])  not start/end with (_ . -)
{
 //  alert(/^[a-zA-Z_0-9\.\-]+$/.test(name));
// return /^[a-zA-Z_0-9\.\-]+$/.test(name);
  return /^[a-zA-Z0-9][a-zA-Z_0-9\.\-]*[a-zA-Z0-9]+$/.test(name);
}

