1
How do I make the characters of -
are converted into :
number inside the form.
When pasting a number inside the form, as in the example above; I want the -
are converted into :
, getting 00:00:00:00
.
function substituiPonto(){
valor = document.calcform.visor.value;
document.getElementById("visor").value = valor.replace("-", ":");
}
function tela(){
window.alert(valor);
}
<form name="calcform" method="post" action="">
<input type="text" name="visor" id="visor" value="" onKeyPress="substituiPonto()"/>
</form>
For that code I can only convert while I type, and not convert when I give CTRL+V
within the form.
Could include the property
onfocusout="substituiPonto()"
in his input. In his Javascript, instead of using the functionreplace()
, would usereplaceAll()
. Thus, by removing thefocus
of its input, would call the functionsubstituiPonto()
, and makes a replace in all the-
for:
.– Rodrigo
Could you show me what the code looks like for you?
– LucasOtavio
I put in the answer Lucas, see if it solves your problem
– Rodrigo
Excellent friend! Thank you very much!
– LucasOtavio