function CalculaDigitoMod11(e,t,n){var r,i,s,o;for(o=1;o<=t;o++){i=0;r=2;for(s=e.length-1;s>=0;s--){i+=r*parseInt(e.charAt(s));if(++r>n) r=2} e+=i*10%11%10} return e.substr(e.length-t,t)} function isRepeatedNumber(e,t){e=e.replace(/[^\d]/g,"");var r=[1,2,3,4,5,6,7,8,9,0];var i=e.length;t=t==undefined?i-3:t;for(n in r){var s=new RegExp("["+r[n]+"]{"+t+","+i+"}");if(s.test(e)) return false} return true} $.validator.addMethod('telefone',function(e,t){var r=e.replace(/\D/g,'').length===11?new RegExp("^[1-9]{2}([6-8]|9[0-9]?)[0-9]{8}$"):new RegExp("^[1-9]{2}([6-8]|[0-9]?)[0-9]{8}$");return this.optional(t)||r.test(e.replace(/[^0-9]/g,''))},'O número informado não é válido.');$.validator.addMethod('telefone_movel',function(e,t){var r=new RegExp("^[1-9]{2}(9)[0-9]{8}$");return this.optional(t)||r.test(e.replace(/[^0-9]/g,''))},'Por favor incluir o nono dígito para celulares.');$.validator.addMethod("CPF",function(e,t){e=e.replace(/[^\d]/g,"");var n=CalculaDigitoMod11(e.substr(0,e.length-2),2,12)==e.substr(e.length-2);return this.optional(t)||e.length==11&&n&&isRepeatedNumber(e)},"CPF inválido");$.validator.addMethod("CEP",function(e,t){var n=new RegExp("^[0-9]{5}[-]?[0-9]{3}$");return this.optional(t)||n.test(e)&&isRepeatedNumber(e,7)},"CEP inválido.");jQuery.validator.addMethod("CNPJ",function(e,t){e=e.replace(/[^\d]/g,"");var n=CalculaDigitoMod11(e.substr(0,e.length-2),2,9)==e.substr(e.length-2);return this.optional(t)||n&&isRepeatedNumber(e)},"CNPJ inválido.");jQuery.validator.addMethod("date_BR",function(e,t){if(this.optional(t)) return true;var n=/^([0-2][0-9]|3[0-1]).(0[1-9]|1[0-2]).(19[2-9][0-9]|20[0-1][0-6])$/;if(n.test(e)){var r=e.split(/[^\d]/);r[1]=r[1]-1;var i=new Date(r[2],r[1],r[0]);if(i.getDate()!=r[0]||i.getMonth()!=r[1]||i.getFullYear()!=r[2]){return false}else{return true}}else{return false}},"Data inválida");