I have a dynamic form with several hidden inputs and wanted to check by jquery if any one has a certain value in the value is possible?
I have a dynamic form with several hidden inputs and wanted to check by jquery if any one has a certain value in the value is possible?
Good morning Thepeter,
What the code I'm going to do is, in all the hidden inputs, look for the value of the same and compare with the value defined (variable compare_value). I think that's what you want.
var compare_value = 10; // Exemplo de valor a validar.
$("input:hidden").each(function(){ // Loop todas as inputs hiddens
if(this.value == compare_value){ // comparar o valor da input e o valor defenido antes
// Caso a afirmação seja verdadeira do something
}
});
Regards.
If the value is dynamic, that is, it has been changed in relation to what is in the HTML attribute, then you have to iterate the inputs and filter what has the value you are looking for.
Something like this:
var encontrados = $('input:hidden').filter(function(){
return this.value == valorEsperado;
});
Then you can use encontrados.length
if you want to know if there are any, or just use the element (s) in other operations, for example:
encontrados.show();