// create the prototype on the String object, trim function
    
/*String.prototype.trim=function trimStr() 
{
// skip leading and trailing whitespace and return everything in between
    var x = this;
    x = x.replace(/^\s*(.*)/, "$1");
    x = x.replace(/(.*?)\s*$/, "$1");
    return x;
}*/

// this function uses regular expression to valid mobile num ( by Jaipal Singh)
/*function valid(mobilenum)
{
    return (/^(84|00|0|)9[0-9]{9}$/.test(mobilenum)); //return true if valid else false
}*/

function valid(mobile)
{
     var ValidChars = "0123456789"
     for(var i = 0; i < mobile.length ; i++)
     {
	var Char = mobile.charAt(i);
	if (ValidChars.indexOf(Char) == -1)
	{
	    alert("Ce numero est invalide")
	    return false
         }
      }

     var countryCode = "596"
     if(mobile.substr(0,1) == "+")
     {
         alert("Please remove + from the number")
         return false
     }
     if(mobile.substr(0,2)=="00") 
     {
         if(mobile.length<8)
	{	
               alert("Check! Mobile number is less than 8 digits.")
		return false
	}
	if ( mobile.length>12)
	{	
		 alert("Check! Mobile number exceeds the limit.")
         	  return false
	}
     }
	
     else if(mobile.substr(0,1)=="0")
     {
         if(mobile.length<8 || mobile.length>12)
         {
alert("Erreur: Votre numero  doit commencer par 0 et contenir au moins 8 chiffres ")

	     return false	
         }
     }
	if(mobile.length<8 || mobile.length>12)
		{
alert("Erreur: Votre numero  doit commencer par 0 et contenir au moins 8 chiffres ")

			return false
		}
	 return true
}

