3
I’m in need of some help with some basic logic...
I have a form with 4 fields that when I do the submit
on the button, I need to validate if at least one of the search fields has been filled in. I could only validate hi first field, but when I leave the first blank and fill in the second, says that no field has been filled...
Could someone help me?
function valida_form() {
if ((document.getElementById("numeroPedido").value == null || document.getElementById("numeroPedido").value == "") && (document.getElementById("codigoCliente").value == null || document.getElementById("codigoCliente").value == "") && (document.getElementById("dataInicial").value == "" || document.getElementById("dataInicial").value == null) && (document.getElementById("dataFinal").value == "" || document.getElementById("dataFinal").value == null)) {
alert('Informe um filtro de pesquisa.');
return false
} else {
return true
}
}
Please enter the code you have, otherwise we’ll be guessing in the dark.
– Sergio
Function valida_form(){ if((Document.getElementById("numeroPedido").value == null || Document.getElementById("numeroPedido").value == "") &&& (Document.getElementById("codeClient"). value == null || Document.getElementById("codeClient"). value == "") && (Document.getElementById("startPath").value == "" || Document.getElementById("startPath").value == null) && (Document.getElementById("dataFinal").value == "" || Document.getElementById("dataFinal").value == null)){ Alert('Enter a search filter.'); Return false } Else { Return true } }
– Brunão
@Brunão vc could put the html code in the question to understand better?
– William Pereira