function alphanumeric_id(fldname,minlength,maxlength,msg,required)
	{
	str = fldname.value;
	if(str.length == 0){
		alert("please enter "+msg+".");
		fldname.focus();
		return false;
	}

	if(str.length < minlength){
		alert(msg+" must be at least "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

 	if(str.indexOf(" ") >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}
	

	if(str.indexOf('&') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	if(str.indexOf("'") >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	if(str.indexOf('"') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	if(str.indexOf('`') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}
	if(str.indexOf(';') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	return true;
}

function numerical_id(fldname,minlength,maxlength,minvalue,msg,required)
	{
	indx = "0123456789";
	str = fldname.value;
	if(required == 'Y')
		{
		if(str.length == 0)
			{
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if((str.length > 0) && (str.length < minlength || str.length > maxlength)){
		alert(msg+" must be "+maxlength+" characters long.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".");
				fldname.focus();
				return false;
			}
		}

		if(parseInt(str) < minvalue){
			alert(msg+" must be more than "+minvalue+".");
			fldname.focus();
			return false;
		}
	}
	return true;
}

function string_value(fldname,minlength,maxlength,msg,required){
	//indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_*!()[]{}:+,/\&# ";
	indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_:/, ";
	str = fldname.value;
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		alert(msg+" must not be less than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed only "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".\nSpecial Characters(! ~ @ # $ % @ ^ & * [] {} +) Not Allowed)");
				fldname.focus();
				return false;
			}
		}

		/* to check whether any character exists or not*/
		flag = 0;
		for(i=0;i<str.length;i++){
			if(str.charAt(i) != " "){
				flag = 1;
				break;
			}
		}

		if(flag == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			fldname.value = "";
			return false;
		}
	}
	return true;
}

function phone_fax(fldname,minlength,maxlength,msg,required)
	{
	indx = "0123456789-[]()";

	str = fldname.value;

	
	
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

if((str.length >0) && (str.length < minlength))
	{
		alert(msg+" allowed minimum "+minlength+" characters.");
		fldname.focus();
		return false;
	}


	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		
			/*
			if(indx.indexOf(str.charAt(0)) <= 0)
				{
				alert("invalid "+msg+".\n must start with '1-9'");
				fldname.focus();
				return false;
			}
			
			*/
			for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".");
				fldname.focus();
				return false;
			}
		}
	}
	return true;
}






function email(fldname,minlength,maxlength,msg,required){
	indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-@.";
	str = fldname.value;

	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".");
				fldname.focus();
				return false;
			}
		}

		if((str.indexOf('@') < 0) || (str.indexOf('.') < 0)){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;			
		}

		if((str.charAt(0) == '@') || (str.charAt(0) == '.')){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}

		if((str.charAt(str.length-1) == '@') || (str.charAt(str.length-1) == '.')){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}

		if((str.indexOf('@@') >= 0) || (str.indexOf('..') >= 0)){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}

		if((str.indexOf('@.') >= 0) || (str.indexOf('.@') >= 0)){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}

		flag = 0;
		for(i=0;i<str.length;i++){
			if(str.charAt(i) == '@')
				flag++;
		}

		if(flag > 1){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}
	}
	return true;
}

function number(fldname,minlength,maxlength,minvalue,maxvalue,msg,required){
	indx = "0123456789";
	str = fldname.value;
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		//alert(msg+" must not be less than "+minlength+" characters.");
		alert(msg+" must  be "+minlength+" characters.");
		fldname.focus();
		return false;
	}
	
	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".");
				fldname.focus();
				return false;
			}
		}

		if(eval(str) < minvalue){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}

		if(eval(str) > maxvalue){
			alert("invalid "+msg+".");
			fldname.focus();
			return false;
		}
	}
	return true;
}

function alpha_numeric_value(fldname,minlength,maxlength,msg,required){
	indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_ ";
	str = fldname.value;

	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		alert(msg+" must be more than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".");
				fldname.focus();
				return false;
			}
		}

		flag = 0;
		for(i=0;i<str.length;i++){
			if(str.charAt(i) != " ")
				flag++;
		}

		if(flag == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			fldname.value = "";
			return false;
		}
	}
	return true;
}

function selectItem(fldname,msg){
	str = fldname.value;
	/*if(parseInt(str) == 0){
		alert(parseInt(str)+"please select "+msg+".");
		fldname.focus();
		return false;
	}*/
	if(fldname.selectedIndex == 0){
		alert("please select "+msg+".");
		fldname.focus();
		return false;
	}
	return true;
}

// not more than current date
function date_validation(fldname_yy,fldname_mm,fldname_dd,month,day,year,current_dd,current_mm,current_yy,msg){
	/*thisdate = new Date();
	mm = thisdate.getMonth()+1;
	dd = thisdate.getDate();
	yy = thisdate.getFullYear*/;

	var mm = current_mm;
	var dd = current_dd;
	var yy = current_yy;

	if(parseInt(year) > yy){
		alert("invalid "+msg+".");
		fldname_yy.focus();
		return false;
	}else if(parseInt(year) == yy){
		if(parseInt(month) > mm){
			alert("invalid "+msg+".");
			fldname_mm.focus();
			return false;
		}else if(parseInt(month) == mm){
			if(parseInt(day) > dd){
				alert("invalid "+msg+".");
				fldname_dd.focus();
				return false;
			}
		}
	}
	return true;
}

function string_value_textarea(fldname,minlength,maxlength,msg,required){
	str = fldname.value;
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		alert(msg+" must not be less than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed only "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		/* to check whether any character exists or not*/
		flag = 0;
		for(i=0;i<str.length;i++){
			if(str.charAt(i) != " "){
				flag = 1;
				break;
			}
		}

		if(flag == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			fldname.value = "";
			return false;
		}
	}
	return true;
}


function birthyear(fldname,minlength,maxlength,minvalue,maxvalue,msg,required){
	indx = "0123456789";
	str = fldname.value;

	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		alert(msg+" must not be less than "+minlength+" characters.");
		fldname.focus();
		return false;
	}
	
	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid value.");
				fldname.focus();
				return false;
			}
		}

		if(parseInt(str) < minvalue){
			alert("birth year must not be less than "+minvalue+".");
			fldname.focus();
			return false;
		}

		if(parseInt(str) > maxvalue){
			alert("below 18 years of age not allowed.");
			fldname.focus();
			return false;
		}
	}
	return true;
}

function uname_string_validation(fldname,minlength,maxlength,msg,required){
	indx = "0123456789_abcdefghijklmnopqrstuvwxyz";
	str = fldname.value;
	if(str.length == 0){
		alert("please enter "+msg+".");
		fldname.focus();
		return false;
	}

	if(str.length < minlength){
		alert(msg+" must be more than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(indx.indexOf(str.charAt(0)) < 11){
				alert("Invalid "+msg+". \ Username must start with small alphabets 'a-z'.");
				fldname.focus();
				return false;
			}	

	

	if(str.length > 0){
		
		if(str.indexOf(" ") >= 0){
		alert("Invalid "+msg+". Username can not have Blank space.");
		fldname.focus();
		fldname.value = "";
		return false;
	}
		
	
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("\tInvalid "+msg+"."+"\n"+"Only letters, numbers and _ are allowed");
//				alert("invalid "+msg+". \ Username can not have blank \& special Characters.");
				fldname.focus();
				return false;
			}
		}
	}

	/*if(str.indexOf('&') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}*/
	return true; 
}
function pan_val(fldname,minlength,maxlength,required)
{
	//indx = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	indx = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	indx1="0123456789";
	str = fldname.value;
//alert(str.length);
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter PAN.");
			fldname.focus();
			return false;
		}
	}

	if(str.length > maxlength){
		alert(" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}
	if(str.length < minlength){
		alert(" allowed ,minimum "+minlength+" characters.");
		fldname.focus();
		return false;
	}

      if(str.length > 0){
		for(i=0;i<5;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid PAN"+"\n PAN must start with capital 'A-Z'.");
				//alert("Invalid "+msg+". \ Username must start with small alphabets 'a-z'.");
				fldname.focus();
				return false;
			}
		}
	  }

	  if(str.length > 0){
		for(i=5;i<9;i++){
			if(indx1.indexOf(str.charAt(i)) < 0){
				//alert("invalid PAN");
				alert("invalid PAN"+"\n PAN must start with numeric '0-9'.");
				fldname.focus();
				return false;
			}
		}
	  }

	  if(str.length > 0){
		m=9;
			if(indx.indexOf(str.charAt(m)) < 0){
				//alert("invalid PAN");
				alert("invalid PAN"+"\n PAN must end with capital 'A-Z'.");
				fldname.focus();
				return false;
			}
		
	  }
	return true;
}

function ifsc_val(fldname,minlength,maxlength,required){

	indx = "0123456789";
	indx1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	str = fldname.value;

	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter valid ifsc code.");
			fldname.focus();
			return false;
		}
	}

	if((str.length < minlength) || (str.length > maxlength)){
		alert("Ifsc code must be 11 characters long.");
		//fldname.focus();
		str=" ";
		return false;
	}

	//if(str.length > maxlength){
//		alert(msg+" allowed maximum "+maxlength+" characters.");
//		fldname.focus();
//		return false;
//	}

	if(str.length > 0){
		for(i=0;i<4;i++){
			if(indx1.indexOf(str.charAt(i)) < 0){
				alert("invalid ifsc code"+"\n Ifsc code must start with capital 'A-Z'.");
				//fldname.focus();
				str=" ";
				return false;
			}
		}
	  }
	  /*if(str.length > 0){
		for(i=4;i<11;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				//alert("invalid PAN");
				alert("invalid ifsc code"+"\n Ifsc code must start with numeric '0-9' after four 'A_Z' letters.");
				//fldname.focus();
				str=" ";
				return false;
			}
		}
	  }
*/
return true;
	
}

function checkboxvalidation(formName,fieldName,link1,link2,link3,link4,required)
{
	
if(required == 'Y' || required == 'y')
	{

			var docformName=eval(formName)
			if(fieldName[0].checked == true)
				{
		
					docformName.action = link1;
					docformName.submit();
				}
			if(fieldName[1].checked == true)
				{
		
					docformName.action = link2;
					docformName.submit();
				}
			if(fieldName[1].checked == true)
				{
	
					docformName.action = link3;
					docformName.submit();
				}
				if(fieldName[2].checked == true)
				{
	
					docformName.action = link4;
					docformName.submit();
				}
		}
	else
	{
	return true;
	}
	
}

function onloadFocus(fieldName)
{
fieldName.focus();
}

function goback(formName,url)
{
formName.action = url;
formName.submit();
}

//checkallval('document.form1','Check_All',document.form1.scripts,'hiddenfieldname')
//checkbox name must be same and take one hidden field to post selected checkbox 
//values(that valus will go with comma),
//but u must trim that hidden value and thus u will got all checkbox values.
// in php trim(hiddenFieldsname,",")
function checkall(formname,fieldValue,form,hiddenFieldsname)
{
	var docformfield=eval(formname+"."+fieldValue)
	var dochiddenfield=eval(formname+"."+hiddenFieldsname)
	var str="";
	if(docformfield.value=='checkall')
		{
	for(i=0;i<form.length;i++)
	{
	form[i].checked=true;
	docformfield.value='uncheckall'
	str=str+","+form[i].value;
	}
	dochiddenfield.value=""+str;
	
}
else
	{
for(i=0;i<form.length;i++)
	{
	form[i].checked=false;
	docformfield.value='checkall'
	dochiddenfield.value=" ";
	}
}
}




function zipcode(fldname,minlength,maxlength,minvalue,msg,required)
	{
	indx = "0123456789";
	str = fldname.value;
	if(required == 'Y')
		{
		if(str.length == 0)
			{
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if((str.length > 0) && (str.length < minlength || str.length > maxlength)){
		alert(msg+" must be "+maxlength+" characters long.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=1;i<str.length;i++){
			if(indx.indexOf(str.charAt(0))==0){
				alert("invalid "+msg+".\n ZIP Code must start by '1-9'.");
				fldname.focus();
				return false;
			}
		
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".\n ZIP Code must be '1-9'.");
				fldname.focus();
				return false;
			}

		}

		if(parseInt(str) < minvalue){
			alert(msg+" must be more than "+minvalue+".");
			fldname.focus();
			return false;
		}
	}
	return true;
}


function bankbranch(fldname,minlength,maxlength,msg,required){
	//indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_*!()[]{}:+,/\&# ";
	indx = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ|()-_:/, ";
	str = fldname.value;
	if(required == 'Y'){
		if(str.length == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			return false;
		}
	}

	if(str.length < minlength){
		alert(msg+" must not be less than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed only "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > 0){
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("invalid "+msg+".\nSpecial Characters(! ~ @ # $ % @ ^ & * [] {} +) Not Allowed)");
				fldname.focus();
				return false;
			}
		}

		/* to check whether any character exists or not*/
		flag = 0;
		for(i=0;i<str.length;i++){
			if(str.charAt(i) != " "){
				flag = 1;
				break;
			}
		}

		if(flag == 0){
			alert("please enter "+msg+".");
			fldname.focus();
			fldname.value = "";
			return false;
		}
	}
	return true;
}






function alphanumeric_id1(fldname,minlength,maxlength,msg,required)
	{
	str = fldname.value;
	if(str.length == 0){
		alert("please enter "+msg+".");
		fldname.focus();
		return false;
	}

	if(str.length < minlength){
		alert(msg+" must be at least "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	/*
	
	if(str.indexOf(" ") >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}
	

	if(str.indexOf('&') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}
*/
	if(str.indexOf("'") >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	if(str.indexOf('"') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	if(str.indexOf('`') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}
	if(str.indexOf(';') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}

	return true;
}

function uname_string_validation_site(fldname,minlength,maxlength,msg,required)
	{
//indx = "0123456789_abcdefghijklmnopqrstuvwxyz-";//=======commented on march_05
	indx = "0123456789_abcdefghijklmnopqrstuvwxyz-.";
	str = fldname.value;
	if(str.length == 0){
		alert("please enter "+msg+".");
		fldname.focus();
		return false;
	}

	if(str.length < minlength){
		alert(msg+" must be more than "+minlength+" characters.");
		fldname.focus();
		return false;
	}

	if(str.length > maxlength){
		alert(msg+" allowed maximum "+maxlength+" characters.");
		fldname.focus();
		return false;
	}

	if(indx.indexOf(str.charAt(0)) < 11){
				alert("Invalid "+msg+". \ Username must start with small alphabets 'a-z'.");
				fldname.focus();
				return false;
			}	

	

	if(str.length > 0){
		
		if(str.indexOf(" ") >= 0){
		alert("Invalid "+msg+". Username can not have Blank space.");
		fldname.focus();
		fldname.value = "";
		return false;
	}
		
	
		for(i=0;i<str.length;i++){
			if(indx.indexOf(str.charAt(i)) < 0){
				alert("\tInvalid "+msg+"."+"\n"+"Only letters, numbers , - and _ are allowed");
//				alert("invalid "+msg+". \ Username can not have blank \& special Characters.");
				fldname.focus();
				return false;
			}
		}
	}

	/*if(str.indexOf('&') >= 0){
		alert("invalid "+msg+".");
		fldname.focus();
		fldname.value = "";
		return false;
	}*/
	return true; 
}
	
function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
} 
/*
if(trim(gname.value) == '')
    {
        alert('Please enter your name');
        gname.focus();
        return false;
    } 

*/