-1
I am having a problem using Jquery, because it is selecting three forms at the same time, and they have different utilities. One is for new user registrations, another for login and one that serves for people to send emails from the site to me (nodemailer).
It all started when I made this third form (email), and began to conflict with others. I say this because after I removed a function the other two forms came back to work. The code I removed was this:
/* Não conheço muito jquery, mas acredito que o problema esteja aqui, pois está selecionando todos os forms certo? mas eu queria selecionar somente o do email */
`$('form').on('submit', (e) => {
e.preventDefault();
const subject = $('#subject').val()//.trim()
const emaill = $('#emaill').val()//.trim()
const text = $('#text').val()//.trim()
const data = {
emaill,
subject,
text
};
//Um dos problemas que noto é que toda vez que tento fazer login ou registra uma
//nova conta, isso aparece no meu terminal, e não deveria.
$.post('/emaill', data, function () {
console.log('Server received our data')
});
$('#formulario').trigger("reset");
$('#resultadoAlter').show() // Faz o alert de mensagem enviada aparecer
});
It is very wide your question, the methods to submit the forms are all in the same file ? have to post all methods and an HTML snippet?
– Pedro Henrique
Take the forms by id, so only one form will be submitted at a time
– PaulinhoCaP