<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

//-----Verifica se um campo não foi informado.
  function verificaVazio(obj) {
     if (obj==null) {
      return true;
    }
    if ((obj.type=="hidden") || (obj.type=="text") || (obj.type=="select-one") || (obj.type=="select") ||  (obj.type=="radio"))  {
      return (obj.value == "") || (obj.value == "null");
    } else {
      return obj.select == 0;
    }
  }

<!--------------- INICIO do script ValidaEmail --------------------->
	function VerificaEmail(email) {
		if (!email) return false;
		var  BadChars = "*|,\":<>[]{}`\';()&$#% ";
		var  GoodChars = "@.";
		for (var i = 0; i < email.length; i++) {
			if (BadChars.indexOf(email.charAt(i)) != -1) {
				return false;
			}
		}
		for (var i = 0; i < GoodChars.length; i++) {
			if (email.indexOf(GoodChars.charAt(i)) == -1) {
				return false;
			}
		}
	 	if (email.indexOf ('@.',0) != -1 || email.indexOf ('.@',0) != -1) {
			return false;
		}
	   return true;
	}
<!--------------- FIM do scripto ValidaEmail --------------------->

<!----------------Início do Script Valida Formato (CEP, DDD, TELEFONE, FAX, RAMAL, ETC) ------------------>
function ValidaFormato(strValidar, constTipo){
    var Exp = ""
    switch (constTipo){
      case "CEP":
        Exp = /^[0-9]{2}[0-9]{3}[0-9]{3}$/;
        break ;
      case "DDD":
        Exp = /^[0-9]{0,5}$/;
        break ;
      case "TELEFONE":
        Exp = /^[0-9]{0,16}$/;
        break ;
      case "RAMAL":
        Exp = /^[0-9]{0,5}$/;
        break ;
      case "FAX":
        Exp = /^[0-9]{0,16}$/;
        break ;
      default :
        return false ;
    }
    if (Exp.test(strValidar)) {
      return true ;
    }else{
      return false ;
    }
}
<!----------------Fim do Script Valida Formato (CEP, DDD, TELEFONE, FAX, RAMAL, ETC) ------------------>
<!-----------Início do Script Valida Data--------------->
var dtCh = "/";
var minYear = 1900;
var maxYear = 2100;

function validaData(strdata){
   return isDate(strdata);
}
function isInteger(s){
   var i;
   for (i = 0; i < s.length; i++){  // Check that current character is number.
      var c = s.charAt(i);
      if (((c < "0") || (c > "9")))
        return false;
   }
   return true; // All characters are numbers.
}
function stripCharsInBag(s, bag){
   var i;
   var returnString = "";
   // Search through string's characters one by one.
   // If character is not in bag, append to returnString.
   for (i = 0; i < s.length; i++){
       var c = s.charAt(i);
       if (bag.indexOf(c) == -1) returnString += c;
   }
   return returnString;
}
function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 ==0))) ? 29 : 28 );
}
function DaysArray(n) {
   for (var i = 1; i <= n; i++) {
	this[i] = 31;
	if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
	if (i==2) {this[i] = 29;}
   }
   return this;
}
function isDate(dtStr){
   var daysInMonth = DaysArray(12);
   var pos1 = dtStr.indexOf(dtCh);
   var pos2 = dtStr.indexOf(dtCh,pos1+1);
   var strDay = dtStr.substring(0,pos1); //pega o dia da string
   var strMonth = dtStr.substring(pos1+1,pos2); //pega o mes da string
   var strYear = dtStr.substring(pos2+1);
   strYr = strYear;
   if (strDay.charAt(0)=="0" && strDay.length > 1)
       strDay=strDay.substring(1);
   if (strMonth.charAt(0)=="0" && strMonth.length > 1)
       strMonth=strMonth.substring(1);
   for (var i = 1; i <= 3; i++) {
       if (strYr.charAt(0)=="0" && strYr.length > 1)
           strYr=strYr.substring(1);
   }
   month = parseInt(strMonth);
   day = parseInt(strDay);
   year = parseInt(strYr);

   if (pos1==-1 || pos2==-1){
      StrGErrosFormato = " deve ser : dd/mm/aaaa";
//      alert("O formato da data deve ser : dd/mm/aaaa");
      return false;
   }
   if (month<1 || month>12){
      StrGErrosFormato = "deve ter um mês válido";
//      alert("Por favor entre com um mês válido");
      return false;
    }
   if (day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day
> daysInMonth[month]){
      StrGErrosFormato = "deve ter um dia válido";
//      alert("Por favor entre com um dia válido");
      return false;
   }
   if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
      StrGErrosFormato = "deve ter 4 digitos entre "+minYear+" e "+maxYear;
//      alert("Por favor entre com um ano válido, deve ter 4 digitos entre "+minYear+" e "+maxYear);
      return false;
   }
   if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
      StrGErrosFormato = "deve ter uma data válida";
//      alert("Por favor entre com uma data válida");
      return false;
   }
 return true;
}

<!----------------Fim do Script Valida Data------------------>


<!-------------Inicio do Script Valida CampoNumero ----------->

function ValidaCampoNumero (strValidar){
 var Exp = ""
   Exp = /^[0-9]{0,15}$/;
   if (Exp.test(strValidar)) {
      return true ;
    }else{
      return false ;
    }
}
<!-------------Fim do Script Valida CampoNumero ----------->


<!-------------Inicio do Script ValidaCNPJ ------------->

   function validaCNPJ(CNPJ) {
                erro = new String;
                if (CNPJ.length < 18) 
                	return false;
                if (CNPJ == "00.000.000/0000-00")
                	return false;
                   	//erro += "É necessario preencher corretamente o número do CNPJ! "; 
                if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
					return false;} else{
				   	//if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! "; }
               		//substituir os caracteres que não são números
                if(document.layers && parseInt(navigator.appVersion) == 4){
                   	 	x = CNPJ.substring(0,2);
                   	 	x += CNPJ. substring (3,6);
                    	x += CNPJ. substring (7,10);
                    	x += CNPJ. substring (11,15);
                    	x += CNPJ. substring (16,18);
                    	CNPJ = x; 
               	} else {
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace ("-","");
                       CNPJ = CNPJ. replace ("/","");
               	}
               	var nonNumbers = /\D/;
               
               	if (nonNumbers.test(CNPJ)) 
               		return false;
               			//erro += "A verificação de CNPJ suporta apenas números! "; 
               	var a = [];
              	var b = new Number;
               	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
               	for (i=0; i<12; i++){
                    a[i] = CNPJ.charAt(i);
                    b += a[i] * c[i+1];
 				}
               	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
               		b = 0;
               	for (y=0; y<13; y++) {
                       b += (a[y] * c[y]); 
               	}
               	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
               	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
                      return false;
                      //erro +="Dígito verificador com problema!";
               	}
               }
               return true;
               //if (erro.length > 0){
               //        alert(erro);
               //        return false;
               //} else {
               //        alert("CNPJ valido!");
               //}
               
       }

<!-------------Fim do Script ValidaCNPJ ------------->

<!-------------Inicio do Script ValidaMoeda ------------->

function validaMoeda (valor){
	reMoeda = /^\d{1,3}(\.\d{3})*\,\d{3}$/;
	if (reMoeda.test(valor)) {
	    return true;
	} else if (valor != null && valor != "") {
		return false;
	}
}

<!-------------Fim do Script ValidaMoeda ------------->


<!-------------Inicio do Script ValidaCGC ------------->
function validaCgc(CNPJ) {
  //algum processamento....
  comErro = !calculoCNPJ_OK(CNPJ);
  // colocar isso sempre que quiser validar no cliente.
//  setErrorMessage(campoCnpj, 'CNPJ Inválido', comErro);
}

function LIMP(c) {
	while((cx=c.indexOf("-"))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf("/"))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf(","))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf("."))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf("("))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf(")"))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	while((cx=c.indexOf(" "))!=-1)
		{		
		c = c.substring(0,cx)+c.substring(cx+1);
		}
	return(c);
	}

function calculoCNPJ_OK(valorCnpj) {
	CNPJ = LIMP(valorCnpj);
	if(CNPJ == 0)
	{
		return true;
	}
	else
	{
		g=CNPJ.length-2;
		if(RealTestaCNPJ(CNPJ,g) == 1)
			{
			g=CNPJ.length-1;
			if(RealTestaCNPJ(CNPJ,g) == 1)
				{	
				return true;
				}
			else
				{
				return false;
				}
			}
		else
			{
			return false;
			}
	}
}
	
function RealTestaCNPJ(CNPJ,g){
	var VerCNPJ=0;
	var ind=2;
	var tam;
	for(f=g;f>0;f--)
		{
		VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind;
		if(ind>8)
			{
			ind=2;
			}
		else
			{
			ind++;
			}
		}
		VerCNPJ%=11;
		if(VerCNPJ==0 || VerCNPJ==1)
			{
			VerCNPJ=0;
			}
		else
			{
			VerCNPJ=11-VerCNPJ;
			}

	if(VerCNPJ!=parseInt(CNPJ.charAt(g)))
		{
		return(0);
		}
	else
		{
		return(1);
		}
}
<!-------------Fim do Script ValidaCNPJ2 ------------->	