Jump to content
Fórum Script Brasil
  • 0

Apenas liberado quando for digitado


RaroPixelado

Question

10 answers to this question

Recommended Posts

  • 0

Primeiramente, crie o button e coloque em sua tag disabled="disabled". Crie o textarea e coloque em sua tag o evento onkeypress="enableButton(this, id)". Agora vamos programar o "enableButton".

function enableButton(textObj, id){
    var buttonObj = document.getElementById(id);
    if (txtObj.value != '')
        buttonObj.disabled = false;
    else
        buttonObj.disabled = true;
}

Teste aí, porque eu não testei. Qualquer dúvida poste aí.

Edited by Rafael P L
Link to comment
Share on other sites

  • 0

<script>
function enableButton(textObj, id){
    var buttonObj = document.getElementById(id);
    if (txtObj.value != '')
        buttonObj.disabled = 'false';
    else
        buttonObj.disabled = 'true';
}
</script>
<input  disabled="disabled" type="button" value="Botão">
<textarea  onkeypress="enableButton(this, id)" ></textarea>

ainda n funciona

Link to comment
Share on other sites

  • 0
<script>

function enableButton(textObj, id){

var buttonObj = document.getElementById(id);

if (txtObj.value != '')

buttonObj.disabled = false;

else

buttonObj.disabled = true;

}

</script>

<input disabled="disabled" type="button" value="Botão">

<textarea onkeypress="enableButton(this, id)" ></textarea>

ainda...

Link to comment
Share on other sites

  • 0

Agora foi.

<script type="text/javascript">

function enableButton(txtObj, id)
{
    var buttonObj = document.getElementById(id);
    if (txtObj.value != '')
        buttonObj.disabled = false;
    else
        buttonObj.disabled = true;
}
</script>

<body>
<form>
    <textarea id="txtTest" onkeyup="enableButton(this, 'btnEnable')"></textarea>
    <input type="button" id="btnEnable" disabled="disabled">
</form>
</body>

Edited by Rafael P L
Link to comment
Share on other sites

  • 0

Cara. Estou muito sem tempo, e vou ficar nos próximos 3 meses. Só após vou estar liberado para participar de algo. Mas me interesso sim, caso ainda precise de mim depois deste tempo.

Faça melhor ainda. Use o evento "onkeyup" ao invés de "onkeypress". Ok?!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...