I have a input
on my form with id="nome"
:
<input id="nome" name="nome" type="text" />
I would like the value of this input
to be equal to: "jose", "maria" or "joao".
I have the following function to check if the value of input
matches one of the names above:
function valida(){
campo = $("#nome");
if(campo.val() == "jose" || campo.val() == "maria" || campo.val() == "joao")
{
alert("Nome válido!");
}else{
alert("Nome inválido!");
}
}
Is it possible, instead of repeating campo.val() == "NOME" ||...
for each name, to make a more simplified comparison, without having to repeat campo.val() ==
for each name only in if
, without using array or other subterfuge out of function?