﻿// JScript File

function AllowAlphabet(e){  
	keyEntry = e.keyCode;
      if(((keyEntry >= '65') && (keyEntry <= '90')) || ((keyEntry >= '97') && (keyEntry <= '122')) || (keyEntry=='46') || (keyEntry=='32') || keyEntry=='45' )       
      return true;        
else            
return false;}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function fnCheckAlphabets()
{
var iAsciiNull="";
if ((window.event.keyCode>=65 && window.event.keyCode<=90) || (window.event.keyCode>=97 && window.event.keyCode<=122) || window.event.keyCode==32)
{ 
return true;
}
else
 
window.event.keyCode=iAsciiNull;
return false; 
}

function containsdigit(param)
{
mystrLen = param.length;
for(i=0;i<mystrLen;i++)
{
if((param.charAt(i)=="0") || (param.charAt(i)=="1") || (param.charAt(i)=="2") || (param.charAt(i)=="3") || (param.charAt(i)=="4") || (param.charAt(i)=="5") || (param.charAt(i)=="6") || (param.charAt(i)=="7") || (param.charAt(i)=="8") || (param.charAt(i)=="9") || (param.charAt(i)=="/"))
{
return true;
}
}
return false;
}
//268261
//function chk()
//{
//
//	if(document.getElementById("txtContactNo").value.trim()=="")
//	{
//		alert("Enter Contact No.!");
//		document.getElementById("txtContactNo").focus();
//		return false;
//	}
//	if (document.getElementById("txtContactNo").value.trim() !="")
//	{
//	    if (checknumber(document.getElementById("txtContactNo").value.trim()))
//	    {
//	       alert("Invalid Contact NO.!")
//	       document.getElementById("txtContactNo").focus();
//	        return false;
//	    }
//		if (parseFloat(document.getElementById("txtContactNo").value.length)<10)
//		{
//				alert("Invalid Mobile NO.!")
//				document.getElementById("txtContactNo").focus();
//				return false;
//		}
//	}
//	document.form1.method="post";
//	document.form1.action="getsmscode.asp";
//	document.form1.submit();
//
//
//
//}
function resetme()
{
	document.getElementById("txtName").value="";
	document.getElementById("txtcity").value="";
	document.getElementById("txtEmail").value="";
document.getElementById("txtContactNo").value=""
}

function ValidateContact()
{
	regExpression = /^[A-Za-z ]*$/ ;
	if(!regExpression.test(document.form1.txtName.value)){
		  alert("Invalid Name");
		  document.form1.txtName.focus();
		  document.form1.txtName.select();
		  return ;
	}
    if((document.getElementById("txtName").value.trim()=="") || (document.getElementById("txtName").value.trim()=="Name") )
	{
		 alert("Enter Name!");
		 document.getElementById("txtName").focus();
		 return ;
  	}
	else if(containsdigit(document.getElementById("txtName").value.trim())==true)
	{
		alert("Name contains numbers!");
		 document.getElementById("txtName").focus();
		return ;
	}

	else if((document.getElementById("txtEmail").value.trim()=="") ||  (document.getElementById("txtEmail").value.trim()=="Email"))
	{
	    alert("Enter Email!");
		document.getElementById("txtEmail").focus();
		 return ;
	}
	else if((document.getElementById("txtContactNo").value.trim()=="") || (document.getElementById("txtContactNo").value.trim()=="Phone No.") )
	{
		alert("Enter Contact No.!");
		document.getElementById("txtContactNo").focus();
		return ;
	}

	else if((document.getElementById("txtcity").value.trim()=="") || (document.getElementById("txtcity").value.trim()=="City") ) 
	{
		 alert("Enter City!");
		 document.getElementById("txtcity").focus();
		 return ;
  	}
	
	
	if((document.getElementById("txtEmail").value.trim() !="") )
	{
	    if(echeck(document.getElementById("txtEmail").value.trim()))
	    {
	    }
	    else
	    {
	        document.getElementById("txtEmail").focus();
	        return ;
	    }
	}
	
	if (document.getElementById("txtContactNo").value.trim() !="")
	{
	    if (checknumber(document.getElementById("txtContactNo").value.trim()))
	    {
	       alert("Invalid Contact NO.!")
	       document.getElementById("txtContactNo").focus();
	        return ;
	    }
		
	}
	
	

	document.form1.method="post";
	//enter your url below here
	//document.form1.action="connectionfile/ins.asp";
	document.form1.action="http://www.expresseasystudent.com/bd/ins.asp";

	document.form1.submit();
//	return true;
}

function checknumber_Old(vSTR)
{
    var anum=/(^\d+$)|(^\d+\.\d+$)/
    if (anum.test(vSTR))
        testresult=false;
    else
    {
        testresult=true;
    }
        return testresult;
}


function checknumber(vSTR)
    {
        var stripped =vSTR.replace(/([0-9\-\+\.\(\)]+)/,'')
        stripped =stripped.replace(/([0-9\-\+\.\(\)]+)/,'')
        //alert(stripped)
        
        if (isNaN(parseInt(stripped)))
        {
            if(stripped=="")
            {
                testresult=false;
            }
            else
            {
                testresult=true;
            }
        }
        else
        {
            testresult=false;
        }
            return testresult;
    }

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 Email Id!");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid Email Id!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
		    alert("Invalid Email Id!");
		    return false;
		}
    	if (str.indexOf(at,(lat+1))!=-1)
		{
		   alert("Invalid Email Id!");
		   return false;
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		   alert("Invalid Email Id!");
		   return false;
		}

		if (str.indexOf(dot,(lat+2))==-1)
		{
		   alert("Invalid Email Id!");
		   return false;
		}
		if (str.indexOf(" ")!=-1)
		{
		   alert("Invalid Email Id!");
		   return false;
		}
		return true;
}


