You can use Client-Side validation with Javascript (pure or using some biliotec like Jquery, Angularjs, etc).
This will occur before you send the data to the server. Something like this:
function Valida() {
if (document.getElementById("nome").value.length < 1) {
alert("Digite um nome.");
document.getElementById("nome").focus();
return false;
} else if (document.getElementById("idade").value.length < 1) {
alert("Digite uma idade.");
document.getElementById("idade").focus();
return false;
} else if (document.getElementById("sexo").value == 0) {
alert("Escolha um sexo.");
document.getElementById("sexo").focus();
return false;
} else {
return true;
}
}
Source: https://bytecrow.wordpress.com/2011/10/17/tutorial-para-iniciantes-05-validacao-de-formulario-com-javascript/
You can (and recommend) validate also on the server side using Nodejs and Javascript.
The code is big, see in https://udgwebdev.com/trabalhando-com-validators-no-node-js.
You can send txt or html emails using nodemailer, plugin for express:
var nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport('smtps://user%40gmail.com:[email protected]');
// setup e-mail data with unicode symbols
var mailOptions = {
from: '"Fred Foo " <[email protected]>', // sender address
to: '[email protected], [email protected]', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ', // plaintext body
html: '<b>Hello world </b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
Source: https://github.com/nodemailer/nodemailer
The javascript part had done at the bottom but the sending of the email always has to be done on the server side. With php/ASP etc..
– Miguel
Node is server, Angularjs is not
– Miguel
I do, but do you want to do the client-side validations in javascript? (as I did below) Or the server-side... Only the server side that can send emails, be it in Node/php/etc..
– Miguel
See http://answall.com/questions/102522/%C3%89-poss%C3%Advel-fazer-autentica%C3%A7%C3%A3o-valida%C3%A7%C3%A3o-de-formul%C3%A1rio-com-Node-js-puro? Rq=1 can be q help. And this https://nodemailer.com/
– Miguel
http://answall.com/q/13298/101
– Maniero
Paul, see this plugin for jquery : https://jqueryvalidation.org
– user49093