
//	Login Lakshya Form Validation (ie email id and password validation)

	function validate_user_login() 
	{
	
//		Receive the email address
		var email=document.member_login.user_email.value;
	
//		Verify whether email address is empty or not
		if(email=="")
		{
			alert("Please enter the useremail");
			document.member_login.user_email.focus();
			return false;
		}
	
//		Verify whether email address entered is valid or not
		else
		{
	
//			Regular Expression for email validation		
			var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			
//			Test whether email address is valid or not
			if(reg.test(email)==false)
			{
				alert('The email ID does not seem to be valid. Please check.');
				document.member_login.user_email.value="";
				document.member_login.user_email.focus();
				return false;
			}
		}
	
//		Receive the password
		var pw=document.member_login.user_password.value;
	
//		Verify whether password is empty or not
		if(pw=="")
		{
			alert("Please enter the password");
			document.member_login.user_password.focus();
			return false;
		}
	
//		If all validations are correct return true
		return true;
	}// Closing of validate_user_login function



//	Email Form Validation (ie name,email and contact number validation)
	function validate_email()
	{
//	Starting of Name Field Validation

//		Receive name
		var name=document.email_form.name.value;
//		Verify whether name is empty or not
		if(name=="")
		{
			alert("PLease enter your name");
			document.email_form.name.focus();
			return false;
		}
		
//		Verify whether name is only alphabate or not
		else
		{
			var reg=/^[A-Za-z][\w]*[A-Za-z]+$/; // regular expression for character only
			if(reg.test(name)==false)
			{
				alert('Please Enter a valid name');
				document.email_form.name.value="";
				document.email_form.name.focus();
				return false;
			}
		}

//	Closing of Name Field Validation

//	Starting of Email Field Validation

//		Receive the email address
		var email=document.email_form.email.value;
	
//		Verify whether email address is empty or not
		if(email=="")
		{
			alert("PLease enter your email address");
			document.email_form.email.focus();
			return false;
		}
	
//		Verify whether email address entered is valid or not
		else
		{
	
//			Regular Expression for email validation		
			var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			
//			Test whether email address is valid or not
			if(reg.test(email)==false)
			{
				alert('The email ID does not seem to be valid. Please check.');
				document.email_form.email.value="";
				document.email_form.email.focus();
				return false;
			}
		}

//	Closing of Email Field Validation

//	Starting of Contact Number Validation

//		Receive Contact Number
		var phone=document.email_form.contact.value;

//		Verify whether contact number is empty or not
		if(phone=="")
		{
			alert("Contact Number is Compulsary");
			document.email_form.contact.focus();
			return false;
		}

//		Verify whether contact number is valid or not
		else
		{
			var reg =/^[0-9][\d\-]*[0-9]$/; // regular expression for contact number

//			Verify whether the contact number is 10/11 digit or not
			var len=document.email_form.contact.value.length;
			if(len <10 || len>11)
			{
				alert("Contact Number must be 10 or 11 digit number only");
				document.email_form.contact.value="";
				document.email_form.contact.focus();
				return false;
			}
				
			else 
			{
				if(reg.test(phone)==false)
				{
					alert("Contact Number must be only number");
					document.email_form.contact.value="";
					document.email_form.contact.focus();
					return false;
				}
			}
		} // Closing of else
		
//	Closing of Contact Number Field Validation

//		If all conditions are true then return true
		return true;
	} // closing validate_user_login function


//	Member Form Registration validation (ie name,email id,password and confirm password validation)
	function validate_member_registeration()
	{

//	Starting of Name Field Validation

//		Receive name
		var name=document.member_registration.name.value;
//		Verify whether name is empty or not
		if(name=="")
		{
			alert("PLease enter your name");
			document.member_registration.name.focus();
			return false;
		}
		
//		Verify whether name is only alphabate or not
		else
		{
			var reg=/^[A-Za-z][\w]*[A-Za-z]+$/; // regular expression for character only
			if(reg.test(name)==false)
			{
				alert('Please Enter a valid name');
				document.member_registration.name.value="";
				document.member_registration.name.focus();
				return false;
			}
		}

//	Closing of Name Field Validation

//	Starting of Email Field Validation

//		Receive the email address
		var email=document.member_registration.email.value;
	
//		Verify whether email address is empty or not
		if(email=="")
		{
			alert("PLease enter your email address");
			document.member_registration.email.focus();
			return false;
		}
	
//		Verify whether email address entered is valid or not
		else
		{
	
//			Regular Expression for email validation		
			var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			
//			Test whether email address is valid or not
			if(reg.test(email)==false)
			{
				alert('The email ID does not seem to be valid. Please check.');
				document.member_registration.email.value="";
				document.member_registration.email.focus();
				return false;
			}
		}

//	Closing of Email Field Validation

//	Starting of Password and confirm password Field Validation

//		Receive Password
		var pw=document.member_registration.password.value;
		
//		Verify whether password is empty or not
		if(pw=="")
		{
			alert("Please enter password");
			document.member_registration.password.focus();
			return false;
		}

//		Receive Confirm Password
		var cnf_pw=document.member_registration.cnf_password.value;

//		Verify whether confirm password is empty or not
		if(cnf_pw=="")
		{
			alert("Please enter confirm password");
			document.member_registration.cnf_password.focus();
			return false;
		}

//		Now verify whether password and confirm password is same or not
		if(pw!=cnf_pw)
		{
			alert("Password and Confirm Password must be same");
			document.member_registration.password.value="";
			document.member_registration.cnf_password.value="";
			document.member_registration.password.focus();
			return false;
		}

//		If all conditions are true return true
		return true;
	}
	

//	Online form submission Field validation
	function validate_online_form_submission()
	{
		return true;
	}
	
//	This is also other techniques to validate a contact number
/*			if(checkPhone(Phone.value)==false)
			{
				alert("Please Enter a Valid Phone Number")
				Phone.value=""
				Phone.focus()
				return false
			}
			var digits = "0123456789";
	
			// non-digit characters which are allowed in phone numbers
			var phoneNumberDelimiters = "()- ";

			// characters which are allowed in international phone numbers
			// (a leading + is OK)
			var validWorldPhoneChars = phoneNumberDelimiters + "+";
	
			// Minimum no of digits in an international phone no.
			var minDigitsInIPhoneNumber = 10;

			function isInteger(s)
			{   
				var i;
				for (i = 0; i < s.length; i++)
				{   
					// Check that current character is number.
					var c = s.charAt(i);
					if (((c < "0") || (c > "9"))) 
						return false;
				}
				// All characters are numbers.
				return true;
			}
			function trim(s)
			{   
				var i;
				var returnString = "";
				// Search through string's characters one by one.
				// If character is not a whitespace, append to returnString.
				for (i = 0; i < s.length; i++)
				{   
					// Check that current character isn't whitespace.
					var c = s.charAt(i);
					if (c != " ") returnString += c;
				}
				return returnString;
			}
			function stripCharsInBag(s, bag)
			{   
				var i;
				var returnString = "";
				// Search through string's characters one by one.
				// If character is not in bag, append to returnString.
				for (i = 0; i < s.length; i++)
				{   
					// Check that current character isn't whitespace.
					var c = s.charAt(i);
					if (bag.indexOf(c) == -1) returnString += c;
				}
				return returnString;
			}
			
			function checkPhone(strPhone)
			{
				var bracket=3
				strPhone=trim(strPhone)
				
				if(strPhone.indexOf("+")>1) 
					return false
				if(strPhone.indexOf("-")!=-1)
					bracket=bracket+1
				if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)
					return false
				var brchr=strPhone.indexOf("(")
				if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")
					return false
				if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)
					return false
				s=stripCharsInBag(strPhone,validWorldPhoneChars);
				return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
			}*/		

function CheckEmpty(cntrl, strMsg)
{
	if (cntrl.value == "")
	{
		alert("Please enter " + strMsg + "!");
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckString(cntrl)
{
	if(!RegExp("^[A-Za-z][\w]*[A-Za-z]+$").test(cntrl.value))
	{
		alert("Please enter alphabets only!");
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPhone(cntrl)
{
	if(!RegExp(/^[0-9][\d\- ]*[0-9]$/).test(cntrl.value))
	{
		alert("Phone number does not appear to be valid. Please check!");
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPhoneLength(cntrl)
{
	var len = cntrl.value.length;
	if(len < 10 || len > 11)
	{
		alert("Phone number does not appear to be valid. Please check its length it must be a 10 digit number!");
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function CheckInteger(cntrl, strMsg)
{   
	var reg =/^[0-9][\d\-]*[0-9]$/;

//	Test whether integer field is valid or not
	//if(isNaN(cntrl))
if(!reg.test(cntrl.value))
	{
		alert(strMsg);
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckAlphaNumerals(cntrl)
{
	if(!RegExp(/^[a-zA-Z][\w\d\ \.,-]*[a-zA-Z0-9]$/).test(cntrl.value))
	{
		alert("Please enter alphanumerals only!");
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPassLength(cntrl)
{
	if (cntrl.value.length < 4)
	{
		alert("Password should have at least four charachers. Please check!");
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckEmail(cntrl)
{
	if(!RegExp(/^\w[\w\-\.]+\@\w[\w\-]+(\.\w[\w\-]+)+$/).test(cntrl.value))
	{
		alert("This Email ID does not appear to be valid. Please check!");
		cntrl.value = "";
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function ConfirmPassword(cntrl1, cntrl2)
{
	if(cntrl1.value != cntrl2.value)
	{
		alert("Password doesn't match with confirmation password. Please check!");
		cntrl1.value = "";
		cntrl2.value = "";
		cntrl1.focus();
		return false;
	}
	else 
	{
		return true;
	}
}

function CheckBox(cntrl , strMsg)
{
	if(cntrl.checked != 1)
	{
		alert("Please " + strMsg + "!");
		cntrl.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidateCaptcha(cntrl1,cntrl2)
{
	if(cntrl1.value != cntrl2.value)
	{
		alert("Please Enter Correctly A Aptcha Text");
		cntrl2.value = "";
		cntrl2.focus();
		return false;
	}
	
	else
		return true;
}

