// Function to remove white spaces staring and ending of string		
function trim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

// This function validate Mobile No. in a control whose ID passed as a parameter.
function ValidateMobileNo(ControlToValidate,ControlToDisplay)
{
	var textValue=document.getElementById(ControlToValidate).value;
	if(isNaN(textValue))
    {
        if(ControlToDisplay=='')
		{
			alert('Please enter numeric value');
		}
		else
		{
			document.getElementById(ControlToDisplay).innerHTML = "Please enter numeric value";
		}
        textValue="";
        document.getElementById(ControlToValidate).focus();
        return false;            
    }
    if(textValue.length<10)
    {
		if(ControlToDisplay=='')
		{
        	alert('Mobile no. must be of 10 digits');
		}
		else
		{
			document.getElementById(ControlToDisplay).innerHTML = "Mobile no. must be of 10 digits";
		}
        document.getElementById(ControlToValidate).focus();            
        return false; 
    }
    if(textValue.charAt(0)!="9")
    {
        if(ControlToDisplay=='')
		{
			alert('Please enter valid mobile no.');
		}
		else
		{
			document.getElementById(ControlToDisplay).innerHTML = "Please enter valid mobile no.";
		}
        document.getElementById(ControlToValidate).focus();            
        return false;
    }  
}
