
//This method identify the special characters
function findSpecialChar(textVal,textName)
{
   var count = 0;
	var specialChar = textVal.value;
	var array1 = new Array("!","#","$","%","^","&","*","(",")","{","}",";","\"","\'","<",">","?","|","+","=","`","~");
	//var array1 = new Array("&","?","+","=","^","$","%",";","\"","\'","<","[","]","[/url]","[url=",".com","<a href =","http://","[link =","</a>");				
	for(j=0;j<array1.length;j++)
	{		
		for(i=0;i<textVal.value.length;i++)
		{
			specialChar = textVal.value;
			if(!(specialChar.indexOf(array1[j])==-1))
			{
				count =1;
				textVal.value = specialChar.replace(array1[j], " ");	
				if(textVal.value.indexOf("  "))
			         textVal.value = textVal.value.replace("  "," ");
				textVal.value = trim(textVal.value);

			}
		}				
	}	
	if(count == 1)
	{
		alert("Some special characters were removed from \""+textName+"\" due to some technical reasons.\nFor List of Special Characters Please go to learning center link in Home Page.\nClick OK to Continue");
		//alert("please remove all special characters from text field");
		count = 0;		
		return 0;		
	}
	return 1;

}

/* *** Allow the "@" , "," , "." , "/" , "[" , "]" , ":" , "-" , "_" , "space bar"  characters provided by CRIS *** */
/* *** Developed By ISHA SONAL *** */

function findSpecialCharByCRIS(textVal,textName)
{
	var count = 0;
	var specialChar = textVal.value;
	var array1 = new Array("!","#","$","%","^","&","*","(",")","{","}",";","\"","\'","<",">","?","|","+","=","`","~");
	for(j=0;j<array1.length;j++)
	{		
		for(i=0;i<textVal.value.length;i++)
		{
			specialChar = textVal.value;
			if(!(specialChar.indexOf(array1[j])==-1))
			{
				count =1;
				textVal.value = specialChar.replace(array1[j], " ");	
				if(textVal.value.indexOf("  "))
			         textVal.value = textVal.value.replace("  "," ");
				textVal.value = trim(textVal.value);

			}
		}				
	}	
	if(count == 1)
	{
		alert("Some special characters were removed from \""+textName+"\" due to some technical reasons.\nFor List of Special Characters Please go to learning center link in Home Page.\nClick OK to Continue");
		//alert("please remove all special characters from text field");
		count = 0;		
		return 0;		
	}
	return 1;

}


/*function findSpecialChar(formName,textName)
{
	//alert("Guna");
   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,[]\ ";
	var checkStr = formName.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Error Code : ADM.015 \nMessage    : Please remove Special Characters in the \""+textName+"\" field.\nFor List of Special Characters Please go to learning center link in Home Page.");
		Some special characters were removed from "+textName+" due to some technical reasons.\nPlease go to learning center link for special character list.
		formName.focus();
		return 0;
	}
	else
		return 1;
	
}*/
//This method used only in case proprietor names fields(IN Vendor Registration Requests)
function propNameSpecilChar(formName,textName)
{
	//alert("Guna");
   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. ";
	var checkStr = formName.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Please Enter only alphabets in the \""+textName+"\" field.");
		formName.focus();
		return 0;
	}
	else
		return 1;
	
}
//This method used to check numeric values
function isNumeric(formvalue, fieldname,fieldfocus)
{
	if (formvalue.match(/^[0-9]+$/))
	{
		return true;
	}
	else
	{
		alert(fieldname + " is not a number");
		fieldfocus.focus();
		return false;
	}
}


//This method identify the special characters in address field
function addressValidation(formName,textName)
{
	//alert("Guna");
   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,&-/ ";
	var checkStr = formName.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Please remove Special Characters in the \""+textName+"\" field.\nFor List of Special Characters Please go to learning center link in Home Page.");
		formName.focus();
		return 0;
	}
	else
		return 1;
	
}


//calling trim function
function trim (s)
{
	return s.replace(/^\s+|\s+$/g,"");
}
//End of trim function


//This mthod used only for User NAmes   
function nameSpecilChar(formName,textName)
{
	//alert("Guna");
   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.";
	var checkStr = formName.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Please Enter only alphabets in the \""+textName+"\" field.");
		formName.focus();
		return 0;
	}
	else
		return 1;
	
}

//This mthod used only for Phone Numbers   
function phoneValidation(formName,textName)
{
	//alert("Guna");
   var checkOK = "0123456789";
	var checkStr = formName.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Please Enter only digits in the \""+textName+"\" field.");
		formName.focus();
		return 0;
	}
	if (formName.value.length > 0)
	{
	  var check = phoneNumberValidation(formName,textName);
		if(check == 0)
			return 0;
	}
	//argha
	if (formName.value.length > 0 && formName.value.length < 8 )
	{
		alert("Please enter minimum 8 digits in '"+textName+"'.");
		formName.focus();
		return 0;
	}
	if(formName.value.length > 12 )
	{
		alert("Maximum 12 digits can be entered in '"+textName+"'.");
        formName.focus();
		return 0;
	}
	
	else
		return 1;
	
}

//Method for validating phone numbers starting with 0 or not
function phoneNumberValidation(textVal,textName)
{
		var phoneVal = textVal.value;
		phoneVal = phoneVal.charAt(0);		
		if(phoneVal != 0)
		{
			alert("Please enter '"+textName+"' starts with '0'");
			textVal.focus();
			return 0;
		}
		else
			return  1;
}


