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

95
Visualizações
Bootstrap datepicker two way function

I have a bootstrap datepicker I wanted to create a date range in one object only and triggered by pressing shift key and when the user clicked ctrl key the function will shift to multi dates is that possible? Sorry I am just a newbie in Javascript. Any help would be very much appreciated. Thank you so much!

Here is what I have so far.

<div class="col-xs-12">
<input class="form-control" type="text" id="multi"  name="multi" required>
<div class="help-block with-errors"></div>
</div>

<script>
    $('#multi').datepicker({
        multidate: true,
        format: 'mm-dd-yyyy',
        forceParse: false

    }).on('hide', function (e) {
        e.stopPropagation();
    })
</script>

$("#multi").on('keydown', function (event) {
if (event.shiftKey === true) {
    isShift = true;
      //alert(isShift);
      console.log(isShift);
  //  isCtrl = false;
} else if (event.ctrlKey === true) {
    //alert('ey ctrl press');
    isCtrl = true;
    console.log(isCtrl);
    //isShift = false;
} else {
   
    return false
}
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Let me understand.. Do you want detect shift and ctrl press, together?

When you press "shift" key, the condition that checks "ctrl" has not been called, because you are using else if.

Try:

$("#multi").on('keydown', function (event) {

if (event.shiftKey === true) {
   isShift = true;
} else {
   isShift = false;
}

if (event.ctrlKey === true) {
    isCtrl = true;
} else {
    isCtrl = false;
}

if(isCtrl && isShift) {

// do something

} else {
    return false;
}

});
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