function validate_chPass(doc)
{
    function blank(doc)
    {
      Namestring = trimWhitespace(doc.frmname.value);      
      Expassstring = trimWhitespace(doc.frmexpass.value);
      newpassstring = trimWhitespace(doc.frmnewpass.value); 
      RePassstring = trimWhitespace(doc.frmretype.value);             
            
      
	str ="";
	 //alert(doc.name);
	if((Namestring == "") || (isAlphanumeric(Namestring) == -1))
	{
		str += " Please enter valid Login name \n"		
	}	       
	if((Expassstring == "") || (isAlphanumeric(Expassstring) == -1))
	{ 
	 str += " Please enter Current valid password \n"	       
	}			 	
	if((newpassstring == "") || (isAlphanumeric(newpassstring) == -1))
	{ 
	       str += " Please enter valid New password \n"	       
	}	
	if((RePassstring == "") || (isAlphanumeric(RePassstring) == -1))
	{
		str += " Please Retype your new password  \n"		
	}		
	if(str)
	{
	   alert(str);
	   return false;
	}
	else
	{
	  return true;	
	}      
    }           

    function chkPass(doc)
    {        
    	if(doc.frmnewpass.value != doc.frmretype.value)
    	{
    	   alert(" New password & Retype New Password do not match\n Please enter the passwords in New password & Retype Password");
    	   return false;
    	}
    	else
    	{
		return true;
    	}
    }

    if(!blank(doc))
    {
    	return false;
    }
    if(!chkPass(doc))
    {
    	return false;
    }
}
function isAlphanumeric(frmfield) {
if (frmfield.search) {
	if ((frmfield.search(/[^\w\s]/) != -1) || (frmfield.search(/\W/) != -1))
	{
		return -1;
	}
}	
return 1;
}

function trimWhitespace(string) {

	var newString  = '';
	var substring  = '';
	beginningFound = false;
	
	// copy characters over to a new string
	// retain whitespace characters if they are between other characters
	for (var i = 0; i < string.length; i++) {
		
		// copy non-whitespace characters
		if (string.charAt(i) != ' ' && string.charCodeAt(i) != 9) {
			
			// if the temporary string contains some whitespace characters, copy them first
			if (substring != '') {
				newString += substring;
				substring = '';
			}
			newString += string.charAt(i);
			if (beginningFound == false) beginningFound = true;			
		}
		
		// hold whitespace characters in a temporary string if they follow a non-whitespace character
		else if (beginningFound == true) substring += string.charAt(i);
	}
	return newString;
}