Block text in textbox

Asked

Viewed 211 times

2

Good morning, you guys. I have this mask made and I need it to block text in the textbox field of my application, but I can’t imagine in any way to do that. (Noob) Could someone help me?

function Mascara(src, mascara) {
    try{

        var campo = src.value.length;
        var saida = mascara.substring(0, 1);
        var texto = mascara.substring(campo);
        if(texto.substring(0, 1) != saida) {
            src.value += texto.substring(0, 1);
        }
    }catch (e){
        ExibeMens ("Ocorreu exceção durante execução !" + e.description, true);
        return false;
    }
}
  • You can explain better what it is ExibeMens and what do you mean by "block text in the textbox field of my application"? you can put HTML you are using?

2 answers

0

<input type="text" id="exemplo" value="Exemplo" disabled />

After you apply the mask put for the inputText field to be disabled with the disable with the following jQuery: $("#exemplo").attr("disabled","disabled")

I hope I helped you!

  • disabled = true does not work with inputs, for whatever reason. The correct is disabled = "disabled". Thus, your example should be edited to $("#example"). attr("disabled","disabled")

-1

If you use the readonly in the input text will not allow editing, read only as the attribute itself says.

<input type="text" readonly name="texto">

  • Production, I took -1 here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.