// JavaScript Document

<!-- Função Cor para a borda do Campo -->
	   function nomecandidatocor() {
      var camponomecandidato=document.inscricoes.nomecandidato.value
      if(camponomecandidato.value==""){
    document.getElementById("nomecandidato");
       }
     else{
    document.getElementById("nomecandidato");
        }
     }
	 
	 function fotocandidatocor() {
      var campofotocandidato=document.inscricoes.fotocandidato.value
      if(campofotocandidato.value==""){
    document.getElementById("fotocandidato");
       }
     else{
    document.getElementById("fotocandidato");
        }
     }
	 
	 function cursocandidatocor() {
      var campocursocandidato=document.inscricoes.cursocandidato.value
      if(campocursocandidato.value==""){
    document.getElementById("cursocandidato");
       }
     else{
    document.getElementById("cursocandidato");
        }
     }


    <!-- Validação em JavaScript -->
		function ValidaInscricoes(inscricoes)
        {
			
	  //validar Nome
      if (inscricoes.nomecandidato.value=="")
     {
    alert ("Por favor digite o seu Nome.");	
	document.getElementById("nomecandidato");
	document.inscricoes.nomecandidato.focus();
    return false;
     }
	 
	 //validar Foto
      if (inscricoes.fotocandidato.value=="")
     {
    alert ("Por favor Envie uma foto sua 3X4.");
	document.getElementById("fotocandidato");
	document.inscricoes.fotocandidato.focus();
    return false;
     }
	 
	 //validar Sexo		
         if (!inscricoes.sexocandidato[0].checked && !inscricoes.sexocandidato[1].checked) {
                   alert("Por favor Escolha o seu Sexo.");
                   return false;

         }
		 
		 //validar Curso
      if (inscricoes.cursocandidato.value=="")
     {
    alert ("Por favor digite seu Curso.");	
	document.getElementById("cursocandidato");
	document.inscricoes.cursocandidato.focus();
    return false;
     }
	 
	 //validar Turno
      if (inscricoes.turnocandidato.value=="")
     {
    alert ("Por favor digite seu Turno.");	
    return false;
     }
	
	 //validar Turma
      if (inscricoes.turmacandidato.value=="")
     {
    alert ("Por favor digite a sua Turma.");
    return false;
     }
	
	//validar Série		
         if (!inscricoes.seriecandidato[0].checked && !inscricoes.seriecandidato[1].checked) {
                   alert("Por favor Selecione sua Série.");
                   return false;

         }
	
	//validar DataNascimento
      if (inscricoes.datanascimentocandidato.value=="")
     {
    alert ("Por favor digite sua Data de Nascimento.");
    return false;
     }
	 
	 //validar RG
      if (inscricoes.rgcandidato.value=="")
     {
    alert ("Por favor digite seu RG.");
    return false;
     }
	 
	 //validar CPF
      if (inscricoes.cpfcandidato.value=="")
     {
    alert ("Por favor digite seu CPF.");
    return false;
     }
	 
	 //validar Email
      if (inscricoes.emailcandidato.value=="")
     {
    alert ("Por favor digite seu E-mail.");
    return false;
     }
	 
	 //validar Número do Registro de Nascimento
      if (inscricoes.numeroregistronascimentocandidato.value=="")
     {
    alert ("Digite o número de seu Registro de Nascimento.");
    return false;
     }
	 
	 //validar Livro Registro de Nascimento
      if (inscricoes.livroregistronascimentocandidato.value=="")
     {
    alert ("Campo Livro em Branco!");
    return false;
     }
	 
	 //validar FLS do Registro de Nascimento
      if (inscricoes.flsregistronascimentocandidato.value=="")
     {
    alert ("Campo FLS em Branco!");
    return false;
     }
	 
	 //validar Cartório do Registro de Nascimento
      if (inscricoes.cartorioregistronascimentocandidato.value=="")
     {
    alert ("Campo Cartório em Branco!");
    return false;
     }
	 
	  //validar UF do Registro de Nascimento 
    if (inscricoes.ufregistronascimentocandidato.selectedIndex==0){ 
       alert("Selecionar o Estado de seu Registro de Nascimento.") 
       inscricoes.ufregistronascimentocandidato.focus() 	   
       return false; 
    } 
	
	//validar Nome do Pai
      if (inscricoes.nomepaicandidato.value=="")
     {
    alert ("Por favor digite o Nome de seu Pai.");
    return false;
     }
	 
	 //validar Nome da Mãe
      if (inscricoes.nomemaecandidato.value=="")
     {
    alert ("Por favor digite o Nome de sua Mãe.");
    return false;
     }
	 
	 //validar Endereço
      if (inscricoes.enderecocandidato.value=="")
     {
    alert ("Por favor digite seu Endereço.");
    return false;
     }
	 
	 //validar Número
      if (inscricoes.numerocandidato.value=="")
     {
    alert ("Digite o Número de sua Residência.");
    return false;
     }
	 
	 //validar Bairro
      if (inscricoes.bairrocandidato.value=="")
     {
    alert ("Por favor digite o seu Bairro.");
    return false;
     }
	 
	 //validar Cidade
      if (inscricoes.cidadecandidato.value=="")
     {
    alert ("Por favor digite sua Cidade.");
    return false;
     }
	 
	 //validar Naturalidade
      if (inscricoes.naturalidadecandidato.value=="")
     {
    alert ("Por favor digite sua Naturalidade.");
    return false;
     }
	 
	 //validar Estado Civil 
    if (inscricoes.estadocivilcandidato.selectedIndex==0){ 
       alert("Selecione seu Estado Civil.") 
       inscricoes.estadocivilcandidato.focus() 	   
       return false; 
    } 
	
	//validar UF
    if (inscricoes.ufcandidato.selectedIndex==0){ 
       alert("Por favor Selecione seu Estado.") 
       inscricoes.ufcandidato.focus() 	   
       return false; 
    } 
	
	//validar CEP
      if (inscricoes.cepcandidato.value=="")
     {
    alert ("Por favor digite seu CEP.");
    return false;
     }
	 
	 //validar Telefone
      if (inscricoes.telefonecandidato.value=="")
     {
    alert ("Por favor digite seu Telefone.");
    return false;
     }
	
	
	 return true;
}
	
     
     
 <!--Adiciona Mascaras para os Campos-->
     
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

<!--Função para validar E-mail-->
function ValidaEmail()
{
  var obj = eval("document.forms[0].email");
  var txt = obj.value;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 0)))
  {
    alert('Email incorreto!');
	obj.focus();
       
  }
}


<!--Função para Validar CPF-->
function validaCPF(cpf)   
{   
  erro = new String;   
  
    if (cpf.value.length == 11)   
    {     
            cpf.value = cpf.value.replace('.', '');   
            cpf.value = cpf.value.replace('.', '');   
            cpf.value = cpf.value.replace('-', '');   
  
            var nonNumbers = /\D/;   
       
            if (nonNumbers.test(cpf.value))   
            {   
                    erro = "A verificacao de CPF suporta apenas números!";   
            }   
            else   
            {   
                    if (cpf.value == "00000000000" ||   
                            cpf.value == "11111111111" ||   
                            cpf.value == "22222222222" ||   
                            cpf.value == "33333333333" ||   
                            cpf.value == "44444444444" ||   
                            cpf.value == "55555555555" ||   
                            cpf.value == "66666666666" ||   
                            cpf.value == "77777777777" ||   
                            cpf.value == "88888888888" ||   
                            cpf.value == "99999999999") {   
                               
                            erro = "Número de CPF inválido!"   
                    }   
       
                    var a = [];   
                    var b = new Number;   
                    var c = 11;   
  
                    for (i=0; i<11; i++){   
                            a[i] = cpf.value.charAt(i);   
                            if (i < 9) b += (a[i] * --c);   
                    }   
       
                    if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }   
                    b = 0;   
                    c = 11;   
       
                    for (y=0; y<10; y++) b += (a[y] * c--);   
       
                    if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }   
       
                    if ((cpf.value.charAt(9) != a[9]) || (cpf.value.charAt(10) != a[10])) {   
                        erro = "Número de CPF inválido.";   
                    }   
            }   
    }   
    else   
    {   
        if(cpf.value.length == 0)   
            return false   
        else   
            erro = "Número de CPF inválido.";   
    }   
    if (erro.length > 0) {   
            alert(erro);   
            cpf.focus();   
            return false;   
    }     
    return true;       
}   


<!-- Funções para inserir máscara nos campos-->
function mcep(v){
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/^(\d{5})(\d)/,"$1-$2")         //Esse é tão fácil que não merece explicações
	return v
	}

function mdata(v){
	v=v.replace(/\D/g,"");                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{2})(\d)/,"$1/$2");
	v=v.replace(/(\d{2})(\d)/,"$1/$2");
	v=v.replace(/(\d{2})(\d{2})$/,"$1$2");
	return v;
	}
	
function mtel(v){
	v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
	v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
	v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
	return v
	}
	
function mrg(v){
	 v=v.replace(/\D/g,"");                                      //Remove tudo o que não é dígito
	 v=v.replace(/(\d)(\d{7})$/,"$1.$2");    //Coloca o . antes dos últimos 3 dígitos, e antes do verificador
	 v=v.replace(/(\d)(\d{4})$/,"$1.$2");    //Coloca o . antes dos últimos 3 dígitos, e antes do verificador
	 v=v.replace(/(\d)(\d)$/,"$1-$2");               //Coloca o - antes do último dígito
	 return v;
	 }
	
function mcpf(v){
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function Integer(v){
        return v.replace(/\D/g,"")
    }
	
	
	
function somente_letra_maiscula(campo){   
   var digits="ABCDEFGHIJLMNOPQRSTUVXZ"   
   var campo_temp   
    for (var i=0;i<campo.value.length;i++){   
        campo_temp=campo.value.substring(i,i+1)   
        if (digits.indexOf(campo_temp)==-1){   
            campo.value = campo.value.substring(0,i);   
        }   
    }   
}   


function somente_letra(campo){   
   var digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"   
   var campo_temp   
    for (var i=0;i<campo.value.length;i++){   
        campo_temp=campo.value.substring(i,i+1)   
        if (digits.indexOf(campo_temp)==-1){   
            campo.value = campo.value.substring(0,i);   
        }   
    }   
}   


        <!-- Fim Validação em JavaScript -->
		<!-- Fim das Funções em JavaScript -->
        <!--Fim das Mascaras para os Campos-->
