-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (35 loc) · 846 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var nome = document.getElementById("nome");
var idade = document.getElementById("idade");
var profissao = document.getElementById("profissao");
function criarPessoa(){
verificaCampos();
}
function limparCampos(){
document.getElementById("nome").value = "";
document.getElementById("idade").value = "";
document.getElementById("profissao").value = "";
}
function isNull(id){
if(id.value == ""){
return true;
}
return false;
}
function verificaCampos(){
if( (isNull(nome)) || (isNull(idade)) || (isNull(profissao)) ){
window.alert("Nenhum Campo pode ficar vazio!");
}
else{
var pessoa = {
"nome": nome.value,
"idade": idade.value,
"profissao": profissao.value
};
console.log(
"Nome: " + pessoa.nome + "\n" +
"Idade: "+ pessoa.idade + "\n" +
"Profissão: " + pessoa.profissao
);
limparCampos();
}
}