1//------------------------------------------------------------------------------ 2//função para fazer a validação de um campo 3function checar(form){ 4 var f = document.forms[form]; 5 var quant = f.elements.length; 6 7 8 9 for(var i = 0; i < quant; i++){ 10 var ele = document.forms[form].elements[i]; 11 var el = document.forms[form].elements; 12 if(ele.getAttribute('vazio') == 'false'){ 13 14 if(ele.getAttribute('type') == 'radio'){ 15 var radiogroup = el[ele.name]; 16 var itemchecked = false; 17 for(var j = 0 ; j < radiogroup.length; j++){ 18 if(radiogroup[j].checked){ 19 var itemchecked = true; 20 } 21 } 22 if (!itemchecked){ 23 var nom = ele.getAttribute('nometx'); 24 alert ('Você precisa preencher o campo ' + nom + '.'); 25 if(ele.focus) 26 ele.focus(); 27 return false; 28 break; 29 } 30 } 31 32 else if(ele.getAttribute('type') == 'checkbox'){ 33 var checkitem = el[ele.name]; 34 var itemchecked = false; 35 if(checkitem.checked){ 36 var itemchecked = true; 37 } 38 if (!itemchecked){ 39 var nom = ele.getAttribute('nometx'); 40 alert ('Você precisa preencher o campo ' + nom + '.'); 41 if(ele.focus) 42 ele.focus(); 43 return false; 44 break; 45 } 46 } 47 48 else{ 49 if(ele.value == ""){ 50 var nom = ele.getAttribute('nometx'); 51 alert('Voce precisa preencher o campo ' + nom + '.'); 52 ele.focus(); 53 return false; 54 break; 55 } 56 } 57 } 58 } 59} 60//------------------------------------------------------------------------------ 61 62//Formata o número do telefone com DDD 63function DDDTelefoneFormat(Campo, e) { 64 var key = ''; 65 var len = 0; 66 var strCheck = '0123456789'; 67 var aux = ''; 68 var whichCode = (window.Event) ? e.which : e.keyCode; 69 70 if (whichCode == 13 || whichCode == 8 || whichCode == 0) 71 { 72 return true; // Enter backspace ou FN qualquer um que não seja alfa numerico 73 } 74 key = String.fromCharCode(whichCode); 75 if (strCheck.indexOf(key) == -1){ 76 return false; //NÃO E VALIDO 77 } 78 79 aux = DDDTelefone_Remove_Format(Campo.value); 80 81 len = aux.length; 82 if(len>=11) 83 { 84 return false; //impede de digitar um telefone maior que 11 (com ddd) 85 } 86 aux += key; 87 88 Campo.value = DDDTelefone_Mont_Format(aux); 89 return false; 90} 91 92function DDDTelefone_Mont_Format(Telefone) 93{ 94 var aux = len = ''; 95 96 len = Telefone.length; 97 if(len<=10) 98 { 99 tmp = 2; 100 tmp2 = 6; 101 } 102 else 103 { 104 tmp = 2; 105 tmp2 = 7; 106 } 107 108 aux = '('; 109 for(i = 0; i < len; i++) 110 { 111 112 aux += Telefone.charAt(i); 113 114 if(i+1==tmp) 115 { 116 aux += ') '; 117 } 118 119 if(i+1==tmp2) 120 { 121 aux += '-'; 122 } 123 124 } 125 return aux ; 126} 127 128function DDDTelefone_Remove_Format(Telefone) 129{ 130 var strCheck = '0123456789'; 131 var len = i = aux = ''; 132 len = Telefone.length; 133 for(i = 0; i < len; i++) 134 { 135 if (strCheck.indexOf(Telefone.charAt(i))!=-1) 136 { 137 aux += Telefone.charAt(i); 138 } 139 } 140 return aux; 141} 142//------------------------------------------------------------------------------ 143 144//função para validação do e-mail 145function checkmail(txt){ 146 if ((txt.length != 0) && ((txt.indexOf('@') < 1) || (txt.indexOf('.') < 3))) 147 { 148 alert('e-mail inválido, favor corrigir.'); 149 obj.focus(); 150 } 151} 152//------------------------------------------------------------------------------
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.