-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.html
147 lines (128 loc) · 3.88 KB
/
Index.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="Style.css">
<title>Formulario</title
</head>
<body>
<div class="content">
<H1>Formulário</H1>
<form id="form">
<div>
<input type="text" placeholder="Digete Seu Nome" class="inputs required" oninput="nameValidat()">
<span class="Span-required">Nome deve ter no minimo 3 caracteres.</span>
</div>
<div>
<input type="email" placeholder="Digete seu melhor email" class="inputs required" oninput="emailValidate()">
<span class="Span-required">Digite um email valido...</span>
</div>
<div>
<input type="password" placeholder="Senha" class="inputs required" oninput="mainPasswordValidate()">
<span class="Span-required">Digite uma senha com no mínimo 8 caracteres</span>
</div>
<div>
<input type="password" placeholder="Senha confere" class="inputs required" oninput="comparePassword()">
<span class="Span-required">as senhas devem ser compatíveis.</span>
</div>
<textarea class="inputs" name="descricao" id="descricao" cols="25" rows="10" placeholder="Fale um pouco sobre você..."></textarea>
<p>Sexo:</p>
<div class="box-select">
<div>
<input type="radio" id="m" value="m" name="sexo">
<label for="m">Masculino</label>
</div>
<div>
<input type="radio" id="f" value="f" name="sexo">
<label for="f">Feminino</label>
</div>
<div>
<input type="radio" id="o" value="o" name="sexo">
<label for="o">Outro</label>
</div>
</div>
<p>Quais suas experiências?</p>
<div class="box-select">
<div>
<input type="checkbox" id=html" value="html" name="experiências">
<label for="html">html</label>
</div>
<div>
<input type="checkbox" id="css" value="css" name="experiências">
<label for="css">CSS</label>
</div>
<div>
<input type="checkbox" id="Js" value="Js" name="experiências">
<label for="Js">Java script</label>
</div>
</div>
<button id="button" type="submit">enviar</button>
</div>
</svg>
</div>
</form>
</div>
</body>
<script>
const form = document.getElementById('form');
const campos = document.querySelectorAll('.required');
const spans = document.querySelectorAll('.Span-required');
const emailRegex = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
form.addEventListener('submit', (event) => {
event.preventDefault();
nameValidat();
emailValidate();
mainPasswordValidate();
comparePassword();
});
function setError(index){
campos[index].style.border = '2px solid #e63636';
spans[index].style.display = 'block';
}
function removeError(index){
campos[index].style.border = '';
spans[index].style.display = 'none';
}
function nameValidat(){
if (campos[0].value.length < 3)
{
setError(0)
}
else
{
removeError(0)
} }
function emailValidate(){
if(!emailRegex.test(campos[1].value))
{
setError(1);
}
else
{
removeError(1);
}
}
function mainPasswordValidate() {
if(campos[2].value.length < 8)
{
setError(2);
}
else
{
removeError(2)
comparePassword();
}
}
function comparePassword(){
if(campos[2].value == campos[3].value && campos[3].value.length >= 8)
{
removeError(3);
}
else
{
setError(3);
}
}
</script>
</html>