function Valida_CPF(VALOR) {
var ie = (navigator.appName == "Microsoft Internet Explorer");
 
VALOR1 = VALOR
VALOR = VALOR.value
if (ie){
total = VALOR.length
	for (i=0;i<total;i++){
		VALOR = VALOR.replace(String.fromCharCode(46),"")
		VALOR = VALOR.replace(",","")
		VALOR = VALOR.replace("-","")
		VALOR = VALOR.replace("/","")
		VALOR = VALOR.replace(" ","")
	}
}
	if (VALOR == "") 
	    { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()
	      return (false); 
	    } 
	if (((VALOR.length == 11) && (VALOR == 11111111111) || (VALOR == 22222222222) || (VALOR == 33333333333) || (VALOR == 44444444444) || (VALOR == 55555555555) || (VALOR == 66666666666) || (VALOR == 77777777777) || (VALOR == 88888888888) || (VALOR == 99999999999) || (VALOR == 00000000000))) 
	    { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()
	      return (false); 
	    } 

	if (!((VALOR.length == 11) || (VALOR.length == 14))) 
	    { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	    
	      return (false); 
	    } 

	var checkOK = "0123456789"; 
	var checkStr = VALOR; 
	var allValid = true; 
	var allNum = ""; 
	for (i = 0;  i < checkStr.length;  i++) 
	  { 
	    ch = checkStr.charAt(i); 
	    for (j = 0;  j < checkOK.length;  j++) 
	      if (ch == checkOK.charAt(j)) 
	        break; 
	    if (j == checkOK.length) 
	    { 
	      allValid = false; 
	      break; 
	    } 
	    allNum += ch; 
	  } 
	  if (!allValid) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 

	  var chkVal = allNum; 
	  var prsVal = parseFloat(allNum); 
	  if (chkVal != "" && !(prsVal > "0")) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 

	if (VALOR.length == 11) 
	{ 
	  var tot = 0; 

	  for (i = 2;  i <= 10;  i++) 
	    tot += i * parseInt(checkStr.charAt(10 - i)); 

	  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(9))) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 
	  
	  tot = 0; 
	  
	  for (i = 2;  i <= 11;  i++) 
	    tot += i * parseInt(checkStr.charAt(11 - i)); 

	  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(10))) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 
	} 
	else 
	{ 
	  var tot  = 0; 
	  var peso = 2; 
	  
	  for (i = 0;  i <= 11;  i++) 
	  { 
	    tot += peso * parseInt(checkStr.charAt(11 - i)); 
	    peso++; 
	    if (peso == 10) 
	    { 
	        peso = 2; 
	    } 
	  } 

	  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(12))) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 
	  
	  tot  = 0; 
	  peso = 2; 
	  
	  for (i = 0;  i <= 12;  i++) 
	  { 
	    tot += peso * parseInt(checkStr.charAt(12 - i)); 
	    peso++; 
	    if (peso == 10) 
	    { 
	        peso = 2; 
	    } 
	  } 

	  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(13))) 
	  { 
	  	  alert("Favor preencher o CPF corretamente.")
		  //VALOR1.focus()	  
	    return (false); 
	  } 
	} 
	  VALOR1.value = VALOR
	  return(true);
}

/*
Na tela onde será feita a verificação colocar a seguinte linha:

if (Valida_CPF(NOME_DO_CAMPO) == false){
	return false;
}
*/
