2
Good morning,
I have a problem with firefox. I have a methods that clears an input with a value I consider invalid ai in the sequence I give Focus to that input. In Internet Explorer and Chrome it works.
The methods I use are these:
$(".field-date").blur(function () {
if (!DtValida(this.value)) {
MsgAlerta("Data inválida.");
this.value = "";
this.focus();
return false;
}
return true;
});
In Firefox clears the input and shows the message, only the Focus that doesn’t work at all.
Andrew would look like this? $(". field-time"). Blur(Function() { if (!Timevalido(this.value)) { Msgalerta("Invalid time." ); this.value = ""; setTimeout(Function() { $(this). Focus(); }, 0); Return false; } Return true; });
– Eu Kaique
Exactly. When do you put
setTimeout()
with a value of 0, Javascript waits for the Event loop to execute the instruction later. It tests and warns me.– Andrew Ribeiro
So I tested the code I put in the previous answer, I switched pro setTimeout and it worked for IE and Chrome, but for Firefox it still didn’t work.
– Eu Kaique
Instead of
$(this).focus();
, place$(".field-date").focus().
Here worked perfectly.– Andrew Ribeiro
Must have some script of mine interfering so here still two 3 browsers the only one that doesn’t work is firefox.
– Eu Kaique
Kaique, you must be putting it wrong. Really put yourself just
this.focus()
or$(this).focus()
here also did not work. It is a problem in Firefox. However, putting the selector ". field-date" worked.– Andrew Ribeiro