 <!--Regular expressions -->
 function validateDecimal_Float( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a Password supports 
	special characters and here min length  6  max 20 charters.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[0-9]+(\.[0-9]+)?$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validatePassword( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a Password supports 
	special characters and here min length  6  max 20 charters.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateNo_specialchar( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a Password supports 
	special characters and here min length  6  max 20 charters.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[!@#$%^&*()_]$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateCaps_Aplhabets( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string supports 
	caps Alphabets.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[A-Z]+$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}
function validateAplhabets( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string supports 
	Alphabets.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[a-zA-Z\ ]+$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateWebsite( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string supports 
	Website URLs.
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^http:\/\/www\.[a-z]+\.(com)|(org)|(edu)|(net)$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateNumbers( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string supports 
		Only decimal values are allowed. 
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  =/^[\d]+$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}
function validateFull_Name( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a First name 
	  Last Name 
	 Alphabets and space(' ') no special characters min 2 and max 12 
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  = /^[A-Za-z ]{2,12}$/;
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateUser_Name( strValue ) {
	/************************************************
	DESCRIPTION: Supports alphabets and numbers no special 
	characters except underscore('_') min 6 and max 12 characters. 
	
	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  = /^[A-Za-z0-9_]{6,12}$/;
	
	//      /^[a-zA-Z]+[a-zA-Z0-9\.\_]*[a-zA-Z0-9]+$/
	//    * No special characters allowed at starting of username.
	//    * (.-_) dot,dash,underscore may come in between a username.
	//   * End character of username may contain alpha-numeric values.
	
	  //check for valid First name and Last Name
	  return objRegExp.test(strValue);
}

function validateNotEmpty( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string is not all
	  blank (whitespace) characters.
	
	RETURNS:
	   True if valid, otherwise false.
	*************************************************/
	   var strTemp = strValue;
	   strTemp = trimAll(strTemp);
		if(strTemp.length > 0){
		  return true;
	   }
	   return false;
}

function trimAll( strValue ) {
	/************************************************
	DESCRIPTION: Removes leading and trailing spaces.
	
	RETURNS: Source string with whitespaces removed.
	*************************************************/
	 var objRegExp = /^(\s*)$/;
	
		//check for all spaces
		if(objRegExp.test(strValue)) {
		   strValue = strValue.replace(objRegExp, '');
		   if( strValue.length == 0)
			  return strValue;
		}
	
	   //check for leading & trailing spaces
	   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if(objRegExp.test(strValue)) {
		   //remove leading and trailing whitespace characters
		   strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function validateUSZip( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string a United
	  States zip code in 5 digit format or zip+4
	  format. 99999 or 99999-9999

	RETURNS:
	   True if valid, otherwise false.
	
	*************************************************/
	var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	  //check for valid US Zipcode
	  return objRegExp.test(strValue);
}

function validateEmail( strValue) {
	/************************************************
	DESCRIPTION: Validates that a string contains a
	  valid email pattern.

	RETURNS:
	   True if valid, otherwise false.
	
	REMARKS: Accounts for email with country appended
	  does not validate that email contains valid URL
	  type (.com, .gov, etc.) or valid country suffix.
	*************************************************/
	var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@  ([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	
	  //check for valid email
	  return objRegExp.test(strValue);
}

function validateMobile( strValue) {
	/************************************************
	DESCRIPTION: Validates that a string contains a
	  valid email pattern.
	
	RETURNS:
	   True if valid, otherwise false.
	
	REMARKS: Accounts for email with country appended
	  does not validate that email contains valid URL
	  type (.com, .gov, etc.) or valid country suffix.
	*************************************************/
	var objRegExp  =/[\(][\+][\d]{2}[\)][\d]{10}/;
	
	  //check for valid email
	  return objRegExp.test(strValue);
}

function validateUSPhone( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains valid
	  US phone pattern.
	  Ex. (999) 999-9999 or (999)999-9999

	RETURNS:
	   True if valid, otherwise false.
	*************************************************/
	  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	
	  //check for valid us phone with or without space between
	  //area code
	  return objRegExp.test(strValue);
}

function validateInteger( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains only
		valid integer number.
	
	RETURNS:
	   True if valid, otherwise false.
	**************************************************/
	  var objRegExp  = /(^-?\d\d*$)/;
	
	  //check for integer characters
	  if (strValue==0)
		return false;
	  else 
	  return objRegExp.test(strValue);
}

function Optional_INT( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains only
		valid integer number.

	RETURNS:
	   True if valid, otherwise false.
	**************************************************/
	  var objRegExp  = /(^-?\d\d*$)/;
	
	  //check for integer characters
	 
	  return objRegExp.test(strValue);
}

<!-- Ajax script for image validation on client side -->
function image_valid()
{
	image_code=document.getElementById('secCode').value
 	if (window.XMLHttpRequest)
	 {        
		 xmlHttp=new XMLHttpRequest();    
	 }
	 else
	 {                 
		 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
	 } 
	 if (xmlHttp) 
	 {   
		 xmlHttp.open("GET", "../inc/ajax_image_validation.php?secCode="+image_code, false);   
		 xmlHttp.send(null);
		 return xmlHttp.responseText;    
 	 }
	 else
	 {   
		 return false; 
	 }  
}
 function refreshImage()
{
	var url = "../inc/refresh_image.php?p=" + Math.random();
	document.getElementById("verImage").setAttribute('src', url);
}

// THIS FUNCTION WILL PRINT THE ERROR MESSAGES //
 function Display_Error_Div(err_div,div_height,table_id,no_error,error_messages)
{
  	var divTag=document.getElementById(err_div)
	divTag.setAttribute("align","left");
	divTag.style.margin = "10px";
	divTag.className ="cssDiv";	
	divTag.style.visibility='visible';
	pixel_per_line=15;
		
		var add=0;
		var new_height=0;
			new_height= (no_error * pixel_per_line);
			add=div_height;
		temp=new_height + add;
		
		if(no_error>0)
		{
			var tempvar="";
					
			for(j=0; j < no_error;j++)
			{
				tempvar += error_messages[j]+'<br/>';
			}
 			divTag.innerHTML=tempvar;

			new_height+=div_height
			if (validateNotEmpty(table_id)==true)
				document.getElementById(table_id).style.height= new_height + 'px';
			
  			return false;
		}
}
// this function will hide all the arrow images. 
   function Hide_Arrows(array)
 {
	count=array.length;
 	for(j=0; j < count;j++)
	{
  		tempvar = document.getElementById(array[j]).style.visibility='hidden'; 
	}
 }
 // this function will display all the arrow images.
 function Arrow_Gen(No,Arr,Err_No)
{
 	  error_img = 'number_'+Err_No;
 	  document.getElementById(No).src='../images/'+error_img+'.gif';
 	  document.getElementById(No).style.visibility='visible';
	  document.getElementById(Arr).style.visibility='visible';
 }
function Change_Password(pswd,cmpswd,username)
{
	var err_pswd=0;
	if (validateNotEmpty(pswd)==false)
		err_pswd=1;
	else if (validateNotEmpty(cmpswd)==false)
		err_pswd=2;
	/*if (validateNotEmpty(cmpswd)==false && validateNotEmpty(pswd)==false)
		err_pswd=3;*/
	if (validatePassword(pswd)==false && validateNotEmpty(pswd)==true)
		err_pswd=3;
	
 	if (validatePassword(pswd)==true && validateNotEmpty(cmpswd)==true)
	{
		if(pswd!=cmpswd)
		{
			err_pswd=4;
		}
	}
	if (validateUser_Name(username)==true && validatePassword(pswd)==true)
	{ 
		if(pswd==username)
		err_pswd=5;
	}
	return err_pswd;
}
// THIS FUNCTION IS FOR CHECKING TEXT LENGHT IN ADD /UPDATE PROPERTY
function Field_Max_length(field)
{
	field = (field.length);
	error="Description of "+ field +" characters exceeds the maximum allowed: 500.";
	return error;
}
