0
I have to do a form validation for a college job, but it’s not working and I’m not succeeding in finding the error. Grateful for the help.
<script>
$(document).ready( function(){ //Quando documento estiver pronto
$("#tel").mask("(00) 0000-00009");
$('#btn').click( function(){ /* Quando clicar em #btn */
/* Coletando dados */
var nome = $('#nome').val();
var email = $('#email').val();
var tel = $('#tel').val();
var msg = $('#msg').val();
if(nome.indexOf(" ") == -1){
$("#nome").html('Nome invalido')
}
if (nome.length < 10){
$("#nome").html('Nome invalido')
}
if(email != ""){
var filtro = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
if(filtro.test(email)){
return true;
}else {
$("#email").html('O endereço de email fornecido é invalido')
return false;
}
else{
$("#email").html('Forneça um endereço de email')
return false;
}
};
if(msg.length < 1){
$("#msg").html(' Digite a mensagem')
return false;
}
What error appears? Be more specific if possible :)
– MarceloBoni
So it just doesn’t work. It doesn’t show the messages, so I’m confused because I think it’s right.
– Prostetnic Vogon Jeltz
There are a lot of errors visible in this code that you sent rs,when you click on F12 and displays the console, which error message you receive?
– MarceloBoni