//--------- Functions Begin ---------//


function namevalchk(tag)
{    
	var1=tag.value; // tval is textbox(element) checking for characters only
    s=var1.substr(var1.length-1,1); 	 
	m=s.charCodeAt(0);            
	if(!((m>=97 && m<=122 )||(m>=65 && m<=90)||(m==32) || (m==46) || isNaN(m)))
	{		
		ch=var1.substr(0,var1.length-1);		
		tag.value=ch;						
	}
}
function phoneval(tag)
{    
	var1=tag.value; // tval is textbox(element) checking for characters only
    s=var1.substr(var1.length-1,1); 	 
	m=s.charCodeAt(0);            
	if(((m>=32 && m<=42) || (m==44) || (m==46) || (m>=58 && m<=126)))
	{		
		ch=var1.substr(0,var1.length-1);		
		tag.value=ch;						
	}
}


function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}

//--------- Functions End ---------//

function notEmpty(elem, helperMsg)
	{
   if(elem.value.length == 0)
	{
//	if(elem.value == ""){
	alert(helperMsg);
	//elem.focus(); // set the focus to this input
	return false;
		 }
	 return true;
	}
	
function indexformvalidator()
{  

	elForm = document.custdetail;
	
	if(trim(elForm.custname.value) == '')
    {
        alert('Please Enter Customer\'s Name!');
        elForm.custname.focus();
        return false;
    }
	
	if(trim(elForm.mb.value) == '')
    {
        alert('Please Enter Mobile Number!');
        elForm.mb.focus();
        return false;
    }
	
	if(trim(elForm.city.value) == '')
    {
        alert('Please Enter City!');
        elForm.city.focus();
        return false;
    }
}


function validator()
{  

	elForm = document.contactus;
	
	if(trim(elForm.custname.value) == '')
    {
        alert('Please Enter Conatct Persons\'s Name!');
        elForm.custname.focus();
        return false;
    }
	
	if(trim(elForm.compname.value) == '')
    {
        alert('Please Enter Company\'s Name!');
        elForm.compname.focus();
        return false;
    }
	
	if(trim(elForm.mobile.value) == '')
    {
        alert('Please Enter Mobile Number!');
        elForm.mobile.focus();
        return false;
    }
	
	if(trim(elForm.city.value) == '')
    {
        alert('Please Enter Company\'s Name!');
        elForm.city.focus();
        return false;
    }
	
}
