I have a problem when performing a negation when using an IF condition in javascript, I don't know if the syntax is wrong:
var correo = document.getElementById("email").value;
var nom = document.getElementsByName("ciudad")[0].value;
var rs = document.getElementsByName("pais")[0].value;
var tel = document.getElementsByName("mensaje")[0].value;
if (!((correo == "")) || (!((nom == "")) || (!((rs == "")) || (!((tel == "")) { //COMPRUEBO CAMPOS VACÍOS
alert("mensaje al no estar vacíos");
return true;
If you want to check that any of the fields is empty
If you want to check that ALL fields are empty
If you want to check that ALL the fields are complete
Although I recommend you to use the function
isEmpty()
instead ofx == ""