function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 return true;
}
function Validate1()
        {
		   var phone=window.document.paynow.phone.value;
		   var invalid=" ";
		   
		   if(isNaN(phone)||phone.indexOf(" ")!=-1)
           {
              alert("Enter Only number in Phone or Mobile Number")
              return false; 
           }
		     return true;
        }
		function Validate2()
        {
		   var amount=window.document.paynow.amount.value;
		   var invalid=" ";
		   
		   if(isNaN(amount)||amount.indexOf(" ")!=-1)
           {
              alert("Enter Only number in Amount in USD")
              return false; 
           }
		     return true;
        }
		
		/*function space1()
		{
			var invalid=" ";
			if (document.paynow.first_name.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
return true;
		}*
		function space2()
		{
			var invalid=" ";
			if (document.paynow.address1.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
return true;
		} */
		function space3()
		{
			var invalid=" ";
			if (document.paynow.amount.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
return true;
		} 
		
		
function payregform()
{

	var sname=window.document.paynow.sname.value;
	var pname=window.document.paynow.pname.value;
	var address=window.document.paynow.address.value;
	var phone=window.document.paynow.phone.value;
	var mailid=window.document.paynow.mailid.value;
	var subject=window.document.paynow.subject.value;
	var month=window.document.paynow.month.value;
	var year=window.document.paynow.year.value;
	var amount=window.document.paynow.amount.value;
	//var fpdate=window.document.paynow.fpdate.value;
	if(sname=="")
	{
		alert("Please Enter Student Name");
		window.document.paynow.sname.focus();
		return false;
	}
	/*if(!space1(name))
	{
		window.document.paynow.first_name.focus();
		return false;
	}*/
	if(pname=="")
	{
		alert("Please Enter Parent's Name");
		window.document.paynow.pname.focus();
		return false;
	}
	/*if(!space2(pname))
	{
		window.document.paynow.pname.focus();
		return false;
	}*/
	
		if(address=="")
	{
		alert("Please Enter Your Address");
		window.document.paynow.address.focus();
		return false;
	}
	/*if(!space2(address))
	{
		window.document.paynow.address.focus();
		return false;
	}*/
	if(phone=="")
	{
		alert("Please Enter Your Phone or Mobile Number");
		window.document.paynow.phone.focus();
		return false;
	}
	/*if(!space3(phone))
	{
		window.document.paynow.phone.focus();
		return false;
	}*/
		if(!Validate1(phone))
	{
		window.document.paynow.phone.value="";
		window.document.paynow.phone.focus();
		return false;
		
	}
	
	if(mailid=="")
	{
		alert("Please Enter Your Mail-ID");
		window.document.paynow.mailid.focus();
		return false;
	}
	if(!echeck(mailid))
				{
					 window.document.paynow.mailid.value="";
					 window.document.paynow.mailid.focus();
					  return false;
				}

if (document.paynow.subject.selectedIndex == 0 )
    {
		alert("Please Select Your Subject");
		window.document.paynow.subject.focus();
		return false;
	}
if (document.paynow.month.selectedIndex == 0 )
    {
		alert("Please Select Month");
		window.document.paynow.month.focus();
		return false;
	}
	if (document.paynow.year.selectedIndex == 0 )
    {
		alert("Please Select Year");
		window.document.paynow.year.focus();
		return false;
	}
	if(amount=="")
	{
		alert("Please Enter Amount in USD");
		window.document.paynow.amount.focus();
		return false;
	}
	if(!space3(amount))
	{
		window.document.paynow.amount.focus();
		return false;
	}
		if(!Validate2(amount))
	{
		window.document.paynow.amount.value="";
		window.document.paynow.amount.focus();
		return false;
		
	}
	/*if(fpdate=="")
	{
		alert("Please Enter Fees Pay Date");
		window.document.paynow.fpdate.focus();
		return false;
	}*/
	
	return true;
}

