
// ############ VALIDATION FOR USERPROFILE - START ############ // 
function getvalidate(id,divname)
{
	non_alphabetic = /[^A-Za-z \']+/;
	special_symbol = /[\<\>\:\;\/\"\'\%\=\[\]]+/;
	non_numeric = /[^0-9+ ]+/;

	var val = document.getElementById(id).value.trim();
	if(val=='' && id!='mobile_no')
	{	
		var pElement=document.getElementById(divname);
		pElement.innerHTML="<b>Please specify your "+id.replace(/_/g,' ')+"</b>" ;
		document.getElementById(divname).className="errorTextBold";
	}
	else
	{
		var pElement=document.getElementById(divname);
		document.getElementById(divname).className="errorTextBold";	
		document.getElementById(divname).style.display="inline";
		switch(id)
		{
			case 'name':
				if(non_alphabetic.test(val))
					StrError = "<b>Name should contain only alphabate.</b>" ;
				else
					StrError = "";			
				
				break;

			case 'user_id':
			case 'desired_id':
				var id = 'user_id';
				if(val.length<8)
					StrError = "<b>User Id should contain atleast 8 characters.</b>" ;
				else if(special_symbol.test(val))
					StrError = "<b>User Id should not contain special symbols.</b>" ;
				else
					StrError = "";	

				break;
							
			case 'password':
			case 'your_password':
				if(val.length<8)
					StrError = "<b>Password should contain atleast 8 characters.</b>" ;
				else if(special_symbol.test(val))
					StrError = "<b>User Id should not contain special symbols.</b>" ;
				else
						StrError = "";
				
				break;

			case 'mobile_no':
				if(val!='')
				{
					if(non_numeric.test(val))
						StrError = "<b>Mobile no should be in digits.</b>" ;
					else
						StrError = "";
				}
				else
					StrError = "";

				break;

			case 'email':
			case 'email_id':
				var id = 'email';
				if(!validateEmail(val))
					StrError = "<b>Invalid email id.</b>" ;
				else
					StrError = "";

				break;
			
		}
			
			pElement.innerHTML = StrError;
			if(!StrError)
				document.getElementById(divname).style.display="none";

		if(!StrError)
		{
			if((id=='user_id' || id=='desired_id' || (id=='mobile_no' && val!='')|| id=='email'|| id=='email_id') && !StrError)
			{
				document.getElementById(divname).style.display="inline";
				pElement.innerHTML="<blink><b>Checking...</b></blink>";			
				var url="ajax_getvalue.html?"+id+"=" + val + "&flag=userprofile";
				//alert(url + " " + divname);
				return validate(url,divname,'GET',null);	
			}
		}
	}
	
}
// ############ VALIDATION FOR USERPROFILE - END ############ // 



