0
I’m stuck in a jam. I made an html form and created a javascript document, but the function I created does not work (as if it was not called) I tried several things and I still can’t.
Here are the codes:
function validar(){
var d = document.formulario;
if(d.nome.value==""){
alert("Campo em branco");
return false;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Aula Prática</title>
<script type="text/javascript" src="js/formularioScript.js"></script>
<meta charset="UTF-8">
</head>
<body>
<form id="formulario">
<div>
ID: <input type:"text" id="formId" placeholder="Digite sua ID">
<br></br>
</div>
<div>
Nome: <input type="text" id="nome" placeholder="Digite seu nome">
<br></br>
</div>
<div>
CPF: <input type="text" id="formCpf" placeholder="Digite deu CPF">
<br></br>
</div>
<div>
Data: <input type="date" id="formData">
<br></br>
</div>
<div>
Gênero: <input type="integer" id="formGen">
<br></br>
</div>
<div>
Ano: <input type="integer" id="formAno">
<br></br>
</div>
<div>
Semestre: <input type="integer" id="formSem">
<br></br>
</div>
<div>
Número de Disciplinas: <input type="integer" id="formDisci">
<br></br>
</div>
<div>
Email: <input type="text" id="formEmail">
<br></br>
</div>
<div>
Cor Administrador: <input type="text" id="formCor">
<br></br>
</div>
<input type="button" id="validar" value="Confirmar" onclick="validar()">
</form>
</body>
</html>
Thanks for your attention! I made the changes and still not validating, until I redid your code in mine and still will not. I checked if it is no problem in the call of doc js by doc html but it is all ok apparently. :/
– RamonVicente
If you want you can http://www.filedropper.com/ and send you the download link and I’ll take a look
– Miguel
You even changed the name of the button id?
– Miguel
I did. Both the ID and the "name".
– RamonVicente
Thank you very much, I got it! As you and the others guided me I was making the changes and fixing the errors but still it was not enabled Alert() (with the script inside the html or in a part doc). I was able to print only with the script in the html I identified that what was causing the error was this excerpt: src="js/formularyScript.js". I only had to take out the "js/". Again I thank you for all the help!
– RamonVicente
Okay, good, you can accept the answer that helped you most
– Miguel