Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
How can i show hidden input fields

I have a question.

When I have form with lets say about 100 hidden input fields, how can I show them one by one after I press enter in the last shown input field?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This adds a key handler to each type="text" field. The key handler tests whether the field is the last type="text" field, and if the key was the Enter key. If so, it finds the next type="hidden" field, sets its type to "text", and adds the handler to it.

function callback(e){
    if (
        // If it's the last text field
        $(this).index() == $('#demo input[type="text"]').length - 1
            &&
        // And the key pressed is Enter:
        e.which == 13
    ) {
        // Find next hidden field, change it to text, and add the key handler:
        $(this).next('input[type="hidden"]').prop("type", "text").keypress(callback)
    }
}

// Add key handler to all text fields:
$('#demo input[type="text"]').keypress(callback)
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<div id="demo">
    <input type="text">
    <input type="text">
    <input type="text">
    <input type="hidden" value="hidden1">
    <input type="hidden" value="hidden2">
    <input type="hidden" value="hidden3">
</div>

References:

jQuery: how do I check if an element is the last sibling?

How can I detect pressing Enter on the keyboard using jQuery?

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda