Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rickreisdev committed Jan 18, 2023
0 parents commit 50f28da
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 0 deletions.
53 changes: 53 additions & 0 deletions estilo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body{
background: rgb(28, 69, 218);
font: normal 15pt Arial;
}

header{
color: white;
text-align: center;
}

section{
background: rgb(21, 198, 77) ;
border-radius: 10px;
padding: 15px;
width: 500px;
margin: auto;
box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.674);
}

footer{
color: white;
text-align: center;
font-style: italic;
padding: 15px;
font-size: 14px;
}
div#cont{
text-align: center;
}
#btn{
background-color: rgb(251, 252, 251);
border-radius: 10px;
font-size: 19px;
}
#btn:hover{
background-color: rgb(47, 179, 20);
color: white;
}
#txtano{
border-radius: 10px;
text-shadow: none;
}
#cont p{
color: white;
text-shadow: 1px 1px 6px black;
font-size: 20px;
}
#res{
color: white;
text-shadow: 2px 2px 6px black;
text-align: center;
font-size: 16px;
}
Binary file added hAdult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hBaby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hIdoso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hJove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verificador de Idade</title>
<link rel="stylesheet" href="estilo.css">
</head>
<body>
<header>
<h1>Verificador de Idade</h1>
</header>
<section>
<div id="cont">
<p>Digite o ano de Nascimento:
<input class="Iano" type="number" name="txtano" id="txtano" min="0">
</p>
<p>Selecione o sexo:
<input type="radio" name="radsex" id="masc" checked>
<label for="masc">Masculino</label>
<input type="radio" name="radsex" id="fem">
<label for="fem">Feminino</label>
</p>
<p>
<input id="btn" type="button" value="Verificar idade" onclick="verificar()">
</p>
</div>
<div id="res">
Por favor, preencha os dados acima para ver o resultado!
</div>
</section>
<footer>
<p>&copy; CursoemVideo</p>
<p>Desenvolvido por RickReis</p>
</footer>
<script src="script.js"></script>
</body>
</html>
Binary file added mAdult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mBaby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mIdosa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mJove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function verificar(){
var data = new Date()
var ano = data.getFullYear()
var fano = document.getElementById('txtano')
var res = document.querySelector('div#res')

if(fano.value.length == 0 || fano.value > ano){
window.alert('{ERRO} Verifique os dados e tente novamente!')
}else{
var fsex = document.getElementsByName('radsex')
var idade = ano - fano.value
var genero =''
var img = document.createElement('img')
img.setAttribute('id', 'foto')

if(fsex[0].checked){
genero='Homem'
if(idade >=0 && idade <10){
//criança
img.setAttribute('src', 'hBaby.png')
}else if(idade < 21){
//jovem
img.setAttribute('src', 'hJove.png')
}else if(idade < 60){
//adulto
img.setAttribute('src', 'hAdult.png')
}else{
//idoso
img.setAttribute('src', 'hIdoso.png')
}

}else if(fsex[1].checked){
genero='Mulher'
if(idade >=0 && idade <10){
//criança
img.setAttribute('src', 'mBaby.png')
}else if(idade < 21){
//jovem
img.setAttribute('src', 'mJove.png')
}else if(idade < 60){
//adulto
img.setAttribute('src', 'mAdult.png')
}else{
//idoso
img.setAttribute('src', 'mIdosa.png')
}
}
res.style.textAlign='center'
res.innerHTML =`Detectamos ${genero} com idade ${idade} anos.`
res.appendChild(img)
}
}

0 comments on commit 50f28da

Please sign in to comment.