Browse Source

Implementando a validaçao do form Interesses

dev
bianca-maria 3 years ago
parent
commit
57675f0848
2 changed files with 30 additions and 34 deletions
  1. +3
    -6
      index.html
  2. +27
    -28
      scripts/index.js

+ 3
- 6
index.html View File

@ -3,16 +3,13 @@
<head>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>T&iacute;tulo P&aacute;gina Triplo X</title>
<link rel="stylesheet" href="styles/estilos.css"/>
<link rel="stylesheet/less" type="text/css" href="styles/base.less"/>
<script src="scripts/less.min.js" type="text/javascript"></script>
<script src="scripts/index.js" defer></script>
</head>
<body>
<script src="scripts/index.js" defer></script>
<header>
<h1>Smartphone XJK +</h1>
</header>
@ -51,7 +48,7 @@
<div class="form__infor">
<label class="form__infor__label">Nome:</label>
<input id="name" type="text" name="nome" class="form__infor__input"/>
<input id="campo_nome" type="text" name="nome" class="form__infor__input"/>
</div>
<div class="form__infor">
<label class="form__infor__label" for="campo_sobrenome">


+ 27
- 28
scripts/index.js View File

@ -1,44 +1,43 @@
const nome = document.querySelector("#nome");
const nome = document.querySelector("#campo_nome");
const sobrenome = document.querySelector("#campo_sobrenome");
const email = document.querySelector("#campo_email");
const checknews = document.querySelector("#check").checked;
const btnEnviar = document.querySelector("#btn_enviar");
const checknews = document.querySelector("#check");
const btnEnviar = document.getElementById("btn_enviar");
let interesse = [];
btnEnviar.addEventListener("click", function (event) {
event.preventDefault();
enviaDados();
});
function enviaDados() {
if (nome.value == "") {
alert('nome não preenchido')
nome.focus()
return
alert("nome não preenchido");
nome.focus();
return;
}
if (sobrenome.value == "") {
alert('sobrenome não preenchido')
sobrenome.focus()
return
alert("sobrenome não preenchido");
sobrenome.focus();
return;
}
if (email.value == "") {
alert('email não preenchido')
email.focus()
return
alert("email não preenchido");
email.focus();
return;
}
interesse.push(nome.value)
interesse.push(sobrenome.value)
interesse.push(email.value)
alert(interesse)
/*if(checknews.value != ''){
alert('email não preenchido')
email.focus()
return
}*/
if (checknews.checked == "") {
alert("marque a opção corretamente");
//checknews.focus()
return;
}
console.log("terminou a funcao");
}
btnEnviar.addEventListener("click", enviaDados)
// interesse.push(nome.value)
//interesse.push(sobrenome.value)
//interesse.push(email.value)
//console.log(btnEnviar)

Loading…
Cancel
Save