// JavaScript Document

function returnfalse(obj){
	obj.focus();
	return false;
}

//function submitUserNameForm() is to validate the username field
function submitUserNameForm(RegiForm)
{
	//username validation
	if(hasFieldOnlySpaces(RegiForm.txtUserName)==false || isFieldEmpty(RegiForm.txtUserName)==false)
	{
		alert("Please enter User Name");
		RegiForm.txtUserName.focus();
		return false;
	}
	
	//username validation for the username as emailid
/*	if(isFieldEmail(RegiForm.txtUserName)==false)
	{
		alert("Please enter a valid User Name");
		RegiForm.txtUserName.focus();
		return false;		
	} 
*/
	return true;
}

//function submitSecurityQuestionForm is to validate security answer field
function submitSecurityQuestionForm(RegiForm)
{
	//securiy answer validation
	if(hasFieldOnlySpaces(RegiForm.txtSecurityAnswer)==false || isFieldEmpty(RegiForm.txtSecurityAnswer)==false)
	{
		alert("Please enter securiy answer");
		RegiForm.txtSecurityAnswer.focus();
		return false;
	}
	if(isFieldAlphanumericSpace(RegiForm.txtSecurityAnswer)==false) return returnfalse(RegiForm.txtSecurityAnswer);
	
	return true;
}

//function submitSecurityQuestionForm is to validate security answer field
function submitChangePasswordForm(RegiForm)
{
	//old password validation
	if(hasFieldOnlySpaces(RegiForm.txtOldPassword)==false || isFieldEmpty(RegiForm.txtOldPassword)==false)
	{
		alert("Please enter old password");
		RegiForm.txtOldPassword.focus();
		return false;
	}	

/*	
	if(RegiForm.password.value.length<6)
	{
		alert("Password should be minimum 6 characters long");
		RegiForm.password.focus();
		return false;
	}
*/

	//new password validation
	if(hasFieldOnlySpaces(RegiForm.txtNewPassword)==false || isFieldEmpty(RegiForm.txtNewPassword)==false)
	{
		alert("Please enter new password");
		RegiForm.txtNewPassword.focus();
		return false;
	}
	if(RegiForm.txtNewPassword.value.length<8)
	{
		alert("Password should be minimum 8 characters long");
		RegiForm.txtNewPassword.focus();
		return false;
	}
	//if(isFieldPasswordInclude(RegiForm.txtNewPassword)==false) return returnfalse(RegiForm.txtNewPassword);
	
	//confirmpassword validation
	if(hasFieldOnlySpaces(RegiForm.txtConfirmPassword)==false || isFieldEmpty(RegiForm.txtConfirmPassword)==false)
	{
		alert("Please enter confirm password");
		RegiForm.txtConfirmPassword.focus();
		return false;
	}
	
	//check for new & confirm password
	if(RegiForm.txtNewPassword.value!=RegiForm.txtConfirmPassword.value)
	{
		alert('Password and Confirm password do not match');
		RegiForm.txtConfirmPassword.focus();
		return false;
	} 
	
	return true;
}

