1var $=jQuery.noConflict(); 2 3$(document).ready(function() { 4 5 init_interessado_scripts(); 6 7}); 8 9 10 11function init_interessado_scripts(){ 12 13 $('#telefone').mask('(99) 99999999?9'); 14 15 $('#celular').mask('(99) 99999999?9'); 16 17 $('#cep').mask('99999-999'); 18 19 $('#cpfCnpj').mask("99.999.999/9999-99"); 20 21 $('#cpf-responsavel').mask("999.999.999-99"); 22 23 24 25 /** 26 27 * Valida CPF CNPJ 28 29 */ 30 31 jQuery.validator.addMethod("validarCpfCnpj", function(value) { 32 33 var ok = true; 34 35 $("#tipo option:selected").each(function () { 36 37 if($('input[name=pf').is(':checked')){ 38 39 ok = validarCPF($('#cpfCnpj').val()); 40 41 return ok; 42 43 }else if (('input[name=pj').is(':checked')){ 44 45 ok = validarCNPJ($('#cpfCnpj').val()); 46 47 return ok; 48 49 } 50 51 return false; 52 53 }); 54 55 return ok; 56 57 }); 58 59 60 61 jQuery('#form').validate({ 62 63 ignoreTitle: true, 64 65 onkeyup: false, 66 67 onfocusout: false, 68 69 showErrors: function(errorMap, errorList) { 70 71 if(errorList.length > 0){ 72 73 showMsg(errorList[0].message, false); 74 75 } 76 77 }, 78 79 errorContainer: $(""), 80 81 errorPlacement: function(error, element) { 82 83 }, 84 85 rules: { 86 87 tipo: { 88 89 required: true 90 91 }, 92 93 nome: { 94 95 required: true 96 97 }, 98 99 email: { 100 101 required: true, 102 103 email: true 104 105 }, 106 107 telefone: { 108 109 required: true 110 111 }, 112 113 cidade: { 114 115 required: true 116 117 }, 118 119 uf: { 120 121 required: true 122 123 }, 124 125 cpfCnpj:{ 126 127 validarCpfCnpj: true 128 129 } 130 131 }, 132 133 messages: { 134 135 tipo: { 136 137 required: 'Um tipo deve ser selecionado' 138 139 }, 140 141 nome: { 142 143 required: 'Campo Nome obrigatório' 144 145 }, 146 147 email: { 148 149 required: "Campo E-mail obrigatório", 150 151 email: "Formato de E-mail inválido" 152 153 }, 154 155 telefone: { 156 157 required: "Campo Telefone obrigatório" 158 159 }, 160 161 cidade: { 162 163 required: "Campo Cidade obrigatório" 164 165 }, 166 167 uf: { 168 169 required: "Campo UF obrigatório" 170 171 }, 172 173 cpfCnpj:{ 174 175 validarCpfCnpj: 'CPF/CNPJ Inválido' 176 177 } 178 179 }, 180 181 submitHandler: function(form) { 182 183 jQuery(form).ajaxSubmit({ 184 185 //target: '#target'//, // target element(s) to be updated with server response 186 187 beforeSubmit: showRequest, // pre-submit callback 188 189 success: successCallback, // post-submit callback 190 191 // other available options: 192 193 url: 'actions/actions.php', // override for form's 'action' attribute 194 195 type: 'post', // 'get' or 'post', override for form's 'method' attribute 196 197 dataType: 'json', // 'xml', 'script', or 'json' (expected server response type) 198 199 error: errorCallback 200 201 //clearForm: true // clear all form fields after successful submit 202 203 //resetForm: true // reset the form after successful submit 204 205 // $.ajax options can be used here too, for example: 206 207 //Timeout da requisicao ajax 208 209 //timeout: 10000 210 211 }); 212 213 } 214 215 }); 216 217 218 219 // pre-submit callback 220 221 function showRequest(formData, jqForm, options) { 222 223 $.windowlock(true); 224 225 return true; 226 227 } 228 229 230 231 // post-submit callback 232 233 function successCallback(responseText, statusText, xhr, $form) { 234 235 if(responseText['ok'] == true){ 236 237 if(responseText['gotoURL'] !== undefined && responseText['gotoURL'] != ''){ 238 239 window.location = responseText['gotoURL']; 240 241 return true; 242 243 } 244 245 var form = $('#form')[0]; 246 247 form.reset(); 248 249 } 250 251 $.windowlock(false); 252 253 showMsg(responseText["msg"], responseText["ok"]); 254 255 } 256 257 258 259 function errorCallback(responseText, statusText, xhr, $form) { 260 261 $.windowlock(false); 262 263 showMsg('Não foi possÃvel completar sua requisição.', false); 264 265 } 266 267} 268 269
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.