-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.js
More file actions
29 lines (23 loc) · 842 Bytes
/
Copy pathvalidate.js
File metadata and controls
29 lines (23 loc) · 842 Bytes
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
document.getElementById('submit').onclick=function() {
console.log("Debuging3")
var validar = validateForm()
if(validar == false){
return false;
}
}
function validateForm() {
var primeiroNome = document.getElementById('primeiroNome');
var oNome = primeiroNome.value;
if(oNome != "Renan") {
console.log("Debuging1")
var aviso = document.getElementById('target');
aviso.style.color = "red";
aviso.innerHTML = "<h2>Escreva Meu Nome!</h2>";
primeiroNome.select(); //seleciona o texto dentro da tag input para que seja corrigida pelo usuário
//primeiroNome.focus();
return false;
console.log("Debuging2"); //esse log nunca sera exibido no console pois a função para de ser executada logo após o return
}
//Se oNome for igual a Renan vemos que a mensagem abaixo aparece no console.
console.log("Debuging4");
}