I made a validation but I want the message to fill in all the fields to be displayed in a span with javascript:
function validarformulario(){
var nombre,correo,compañia,expresion;
nombre =document.getElementById('nombre').value;
correo=document.getElementById('email').value;
compañia=document.getElementById('compañia').value;
expresion= /^[-\w.%+]{1,64}@(?:[A-Z0-9-]{1,63}\.){1,125}[A-Z]{2,63}$/i;
if ( nombre ==="" || compañia==="" || correo==="" ) {
error.html(<'span>Todos los campos son obligatorios</span>');
return false
}
else if (!expresion.test(email.value)){
error.html('<span>Please enter a valid email address</span>');
return false
}
}