Essa é a linha digitada:
<html>
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="get" action=".">
<div class="objeto">
<div class="row">
<div class="input-field col s6">
<i class="material-icons prefix">person</i>
<input id="Cliente" type="text">
<label for="Cliente">Cliente</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">control_point</i>
<input id="CPF" type="text" onkeyup = "MascaraCPF(this)" maxlength= "14">
<label for="CPF">CPF</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">phone</i>
<input id="Contato1" type="tel" onkeyup = "MascaraTelefone(this)" maxlength="14">
<label for="Contato1">Contato1</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">phone</i>
<input id="Contato2" type="tel" onkeyup = "MascaraTelefone2(this)" maxlength="14">
<label for="Contato2">Contato2</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">email</i>
<input id="E-mail" type="text">
<label for="E-mail">E-mail</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">location_on</i>
<input name= "cep" id="cep" type="text" value="" size="12" maxlength="10"
onkeyup="MascaraCEP(this)"
onblur="pesquisacep(this.value);">
<label for="cep">CEP</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">streetview</i>
<input id="rua" type="text">
<label for="rua">Rua</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">control_point</i>
<input id="Num" type="text">
<label for="Num">Nº</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">control_point</i>
<input id="Complemento" type="text">
<label for="Complemento">Complemento</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">control_point</i>
<input id="bairro" type="text">
<label for="bairro">Bairro</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix">location_city</i>
<input id="cidade" type="text">
<label for="cidade">Cidade</label>
</div>
<div class="input-fiel col s10">
<button class="btn-floating btn-large waves-effect waves-light green" id= "btn1" type="submit" name="action">Salvar
<i class="material-icons right">send</i>
</button>
<button class="btn-floating btn-large waves-effect waves-light light-blue" id= "btn2" type="submit" name="action">Pesq.
<i class="material-icons right">send</i>
</button>
<button class="btn-floating btn-large waves-effect waves-light yellow" id= "btn3" type="submit" name="action">Editar
<i class="material-icons right">send</i>
</button>
<button class="btn-floating btn-large waves-effect waves-light red" id= "btn4" type="submit" name="action">Apagar
<i class="material-icons right">send</i>
</button>
<button class="btn-floating btn-large waves-effect waves-light black" id= "btn5" type="submit" name="action">Fechar
<i class="material-icons right">send</i>
</button>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type = "text/javascript">
function MascaraCPF(){
var CampoCPF = document.getElementById("CPF");
var CPF = CampoCPF.value;
if (CPF.length == 3){
CPF = CPF + "."
CampoCPF.value = CPF;
return true;
};
if (CPF.length == 7){
CPF = CPF + "."
CampoCPF.value = CPF;
return true;
};
if (CPF.length == 11){
CPF = CPF + "-"
CampoCPF.value = CPF;
return true;
};
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type = "text/javascript">
function MascaraCEP(){
var CampoCEP = document.getElementById("cep");
var CEP = CampoCEP.value;
if (CEP.length == 2){
CEP = CEP + "."
CampoCEP.value = CEP;
return true;
}
if (CEP.length == 6){
CEP = CEP + "-"
CampoCEP.value = CEP;
return true;
}
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type = "text/javascript">
function MascaraTelefone(){
var CampoTel = document.getElementById("Contato1");
var Tel = CampoTel.value;
if (Tel.length == 1){
Tel = "(" + Tel
CampoTel.value = Tel;
return true;
}
if (Tel.length == 3){
Tel = Tel + ")"
CampoTel.value = Tel;
return true;
}
if (Tel.length == 9){
Tel = Tel + "-"
CampoTel.value = Tel;
return true;
}
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type = "text/javascript">
function MascaraTelefone2(){
var CampoTel = document.getElementById("Contato2");
var Tel = CampoTel.value;
if (Tel.length == 1){
Tel = "(" + Tel
CampoTel.value = Tel;
return true;
}
if (Tel.length == 3){
Tel = Tel + ")"
CampoTel.value = Tel;
return true;
}
if (Tel.length == 9){
Tel = Tel + "-"
CampoTel.value = Tel;
return true;
}
}
</script>
<script>
var CampoCliente = document.getElementById("Cliente");
var CampoCPF = document.getElementById("CPF");
var CampoContato1 = document.getElementById("Contato1");
var CampoContato2 = document.getElementById("Contato2");
var CampoEmail = document.getElementById("E-mail");
var CampoCEP = document.getElementById("cep");
var CampoRUA = document.getElementById("rua");
var CampoNº = document.getElementById("Num");
var CampoComp = document.getElementById("Complemento");
var CampoBairro = document.getElementById("bairro");
var CampoCidade = document.getElementById("cidade");
document.getElementById("btn1").addEventListener("click", SalvarCliente);
function SalvarCliente(){
var Cliente = CampoCliente.value;
var CPF = CampoCPF.value;
var Contato1 = CampoContato1.value;
var Contato2 = CampoContato2.value;
var Email = CampoEmail.value;
var CEP = CampoCEP.value;
var RUA = CampoRUA.value;
var Num = CampoNº.value;
var Comp = CampoComp.value;
var Bairro = CampoBairro.value;
var Cidade = CampoCidade.value;
if (Cliente.trim().length == 0 ||
CPF.trim().length == 0 ||
Contato1.trim().length == 0 ||
Email.trim().length == 0 ||
CEP.trim().length == 0 ||
RUA.trim().length == 0 ||
Num.trim().length == 0 ||
Bairro.trim().length == 0 ||
Cidade.trim().length == 0 || ){
M.toast({html: "Informações Pendentes"})
}else{
var Dados = {
Cliente: CampoCliente.value,
CPF: CampoCPF.value,
Contato1: CampoContato1.value,
Contato2: CampoContato2.value,
Email: CampoEmail.value,
CEP: CampoCEP.value,
RUA: CampoRUA.value,
Num: CampoNº.value,
Comp: CampoComp.value,
Bairro: CampoBairro.value,
Cidade: CampoCidade.value,
};
google.script.run.withSuccessHandler(Salvar).SalvarCliente(Dados);
function Salvar(Atualizar) {
M.toast({html:Atualizar});
}
CampoCliente.value = "";
CampoCPF.value = "";
CampoContato1.value = "";
CampoContato2.value = "";
CampoEmail.value = "";
CampoCEP.value = "";
CampoRUA.value = "";
CampoNº.value = "";
CampoComp.value = "";
CampoBairro.value = "";
CampoCidade.value = "";
}
};
</script>
<script>
function limpa_formulário_cep() {
//Limpa valores do formulário de cep.
document.getElementById('rua').value=("");
document.getElementById('bairro').value=("");
document.getElementById('cidade').value=("");
}
function meu_callback(conteudo) {
if (!("erro" in conteudo)) {
//Atualiza os campos com os valores.
document.getElementById('rua').value=(conteudo.logradouro);
document.getElementById('bairro').value=(conteudo.bairro);
document.getElementById('cidade').value=(conteudo.localidade);
} //end if.
else {
//CEP não Encontrado.
limpa_formulário_cep();
alert("CEP não encontrado.");
}
}
function pesquisacep(valor) {
//Nova variável "cep" somente com dígitos.
var cep = valor.replace(/\D/g, '');
//Verifica se campo cep possui valor informado.
if (cep != "") {
//Expressão regular para validar o CEP.
var validacep = /^[0-9]{8}$/;
//Valida o formato do CEP.
if(validacep.test(cep)) {
//Preenche os campos com "..." enquanto consulta webservice.
document.getElementById('rua').value="...";
document.getElementById('bairro').value="...";
document.getElementById('cidade').value="...";
//Cria um elemento javascript.
var script = document.createElement('script');
//Sincroniza com o callback.
script.src = 'https://viacep.com.br/ws/'+ cep + '/json/?callback=meu_callback';
//Insere script no documento e carrega o conteúdo.
document.body.appendChild(script);
} //end if.
else {
//cep é inválido.
limpa_formulário_cep();
alert("Formato de CEP inválido.");
}
} //end if.
else {
//cep sem valor, limpa formulário.
limpa_formulário_cep();
}
};
</script>
</body>
</html>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var url = "https://docs.google.com/spreadsheets/d/1I0TpXoJy2CjT5Gwq3Qc6iESauCIVYnIC_2H486JEmQY/edit#gid=533315935"
Array.prototype.Pesquisa = function(Procura){
if (Procura == "") return false;
for ( var Linha = 0; Linha<this.length; Linha ++)
if (this[Linha] == Procura) return Linha;
return - 1
}
function FormCliente (){
var Form = HtmlService.createTemplateFromFile("FormCliente");
var MostrarForm = Form.evaluate();
MostrarForm.setTitle("Cadastro de Clientes").setHeight(550).setWidth(700);
SpreadsheetApp.getUi().showModalDialog(MostrarForm, "Cadastro de Clientes");
};
function SalvarCliente(Dados){
var Planilha = SpreadsheetApp.openByUrl(url);
var Guia = Planilha.getSheetByName("Clientes");
Guia.getActiveCell();
Guia.getRange('B2').activate();
Guia.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN);
Guia.getActiveCell().offset(1, 0).activate();
var Linha = Guia.getCurrentCell().getRow();
var Data = new Date();
Guia.getRange(Linha, 2).setValue(Data);
Guia.getRange(Linha, 3).setValue([Dados.Cliente]);
Guia.getRange(Linha, 4).setValue([Dados.CPF]);
Guia.getRange(Linha, 5).setValue([Dados.Contato1]);
Guia.getRange(Linha, 6).setValue([Dados.Contato2]);
Guia.getRange(Linha, 7).setValue([Dados.Email]);
Guia.getRange(Linha, 8).setValue([Dados.CEP]);
Guia.getRange(Linha, 9).setValue([Dados.RUA]);
Guia.getRange(Linha, 10).setValue([Dados.Num]);
Guia.getRange(Linha, 11).setValue([Dados.Comp]);
Guia.getRange(Linha, 12).setValue([Dados.Bairro]);
Guia.getRange(Linha, 13).setValue([Dados.Cidade]);
return 'Registrado com Sucesso';
};