3
I have the following fields
<input type="text" value="" name="campo" id="campo">
<input type="text" value="" name="campoRecebeDados" id="campoRecebeDados">
And the next jQuery:
$(document).ready(function(){
function setar_valor(){
var campo = $("#campo").val();
$("#campoRecebeDados").val(campo);
}
$(document).on("keyup", "#campo", setar_valor);
});
At the moment I’m using keyup
, which would be in the case if the campo
is completed, it copies the value to the campoRecebeDados
, but as I know (via code) that the campoRecebeDados
was filled out?
I thought I’d make:
if($("#campoRecebeDados")==true){
alert('Preenchido')
}
However, if I do it this way, it will never be true because the fill value=""
field will always be the initial stage, not the one set. (This is seen in the source code);
In this case I already filled a previous field, which filled this, but as you can see value="" remains unchanged.
In this case, I needed the check to be automated.. ie filled, it passed to the other field and automatically check whether the other field was filled or not...
– Sr. André Baill
I didn’t understand the purpose, but I made a change in the answer. I don’t know if that’s what you want.
– Sam