
function fm_val()
{
if ((document.fm_reg.f_name.value)=="")
{
alert("Please enter First Name");
document.fm_reg.f_name.focus();
return false;
}
if ((document.fm_reg.l_name.value)=="")
{
alert("Please enter Last Name");
document.fm_reg.l_name.focus();
return false;
}
if ((document.fm_reg.aff_address.value)=="")
{
alert("Please enter Address");
document.fm_reg.aff_address.focus();
return false;
}

if ((document.fm_reg.aff_city.value)=="")
{
alert("Please enter City");
document.fm_reg.aff_city.focus();
return false;
}
if ((document.fm_reg.aff_state.value)=="")
{
alert("Please enter State");
document.fm_reg.aff_state.focus();
return false;
}
if ((document.fm_reg.aff_country.value)=="")
{
alert("Please enter Country");
document.fm_reg.aff_country.focus();
return false;
}
if ((document.fm_reg.aff_zip.value)=="")
{
alert("Please enter post code code");
document.fm_reg.aff_zip.focus();
return false;
}
if ((document.fm_reg.aff_phone.value)=="")
{
alert("Please enter Phone");
document.fm_reg.aff_phone.focus();
return false;
}

if ((document.fm_reg.aff_emailid.value)=="")
{
alert("Please enter email address");
document.fm_reg.aff_emailid.focus();
return false;
}
else
{
var email=document.fm_reg.aff_emailid.value;
var emailPat =/^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var matchArray = document.fm_reg.aff_emailid.value.match(emailPat);
if (matchArray == null) {
alert("Your E-mail address is invalid");
document.fm_reg.aff_emailid.select();
return false;
		}	
	}
	
if(document.fm_reg.aff_url.value !="")
	{
	var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!v.test(document.fm_reg["aff_url"].value)) {
        alert("Provide valid URL.");
		document.fm_reg.aff_url.select();
        return false;
    } 
		}
if((trimString(document.fm_reg.aff_uname.value)=="")||((trimString(document.fm_reg.aff_uname.value).length)<5))
{alert("Enter User Name with atleast 5 chars:");document.fm_reg.aff_uname.focus();return false;}

if((trimString(document.fm_reg.aff_password.value)=="")||((trimString(document.fm_reg.aff_password.value).length)<5))
{alert("Please enter password with atleast 5 chars");document.fm_reg.aff_password.focus();return false;}
if(trimString(document.fm_reg.aff_repass.value)=="")
{alert("Please enter confirm password ");document.fm_reg.aff_repass.focus();return false;}		
	else
				{
				pass=trimString(document.fm_reg.aff_password.value);
				repass=trimString(document.fm_reg.aff_repass.value);
				if (pass!=repass)
				{
				alert("Password Missmatch")
				document.fm_reg.aff_repass.select();
				return false;
				}
				}	

if ((document.fm_reg.txtpay.value)=="")
{
alert("Please enter Affiliate Paypal email id");
document.fm_reg.txtpay.focus();
return false;
}
else
{
var email1=document.fm_reg.txtpay.value;
var emailPat1 =/^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var matchArray1 = document.fm_reg.txtpay.value.match(emailPat1);
if (matchArray1 == null) {
alert("Your E-mail address is invalid");
document.fm_reg.txtpay.select();
return false;
		}	
	}


return true;
}
// JavaScript Document
function trimString (str)
{
while (str.charAt(0) == ' ')
str = str.substring(1);
while (str.charAt(str.length - 1) == ' ')
str = str.substring(0, str.length - 1);
return str;
}	


