		//removing non-numbers from number fields like tel
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode;
         if (charCode > 31 && (charCode < 46 || charCode > 57 || charCode == 47))
            return false;

         return true;
      }

	//Function validation - general 
	function validate_required(field,alerttxt)
	{
		with (field)
		{
			if (value==null||value=="")
			  {alert(alerttxt);return false}
			else {return true}
		}
	}
	
//email ID checking
function emailcheck(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 true
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return true
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return true
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return true
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return true
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return true
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return true
		 }

 		 return false					
}
	
	
	
	
	//form validation 
	//should be changed to a common format
	//it is not suitable to use this as common - need seperate function for each form/page
	function validate_form_chnage(frm)
	{
		with (frm)
		{
			if (validate_required(txt1,"Please fill Company Name")==false)
			  {txt1.focus();return false}
			else if (validate_required(txt2,"Please fill Address")==false)
			  {txt2.focus();return false}
			else if (validate_required(txt3,"Please fill your name")==false)
			  {txt3.focus();return false}
			else if (validate_required(txtun,"Please fill User Name")==false)
			  {txtun.focus();return false}
			else if (validate_required(txtpw,"Please fill password")==false)
			  {txtpw.focus();return false}
			else if (pwrw.value!=txtpw.value)
			  {
			  alert ("Password Mismatch");
			  txtpw.focus();
			  return false;
			  }
			else if (validate_required(txt7,"Please fill E-mail")==false)
			  {txt7.focus();return false}
			else if (emailcheck(txt7.value))
			{
				txt7.focus();return false
			}		
			else{
				return true;
				}
		}
	}

