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

230
Visualizações
I have added JS function to prevent user to insert invalid date in datepicker. It is working but error alert box is not closed

I am new to JS. I have added JS function to prevent user to insert invalid(like 99/99/0000) date manually in datepicker. I have written all the function and it is working as expected but somehow when you entered the invalid date it throws the error but that alert box is not closed it remains as it is. Please guide me here Thanks in advance.

Function :

    $(function() {
      var dateFormat = "mm/dd/yy";
      var beginDate = $("#dobEdit").datepicker({
          defaultDate: "+1w",
          changeMonth: true,
          changeYear: true
        })

        .on({
          change: function() {
            beginDate.datepicker("option", "minDate", getDate(this));
          },
          blur: function() {
            beginDate.datepicker("option", "minDate", getDate(this));
          }
        });

      function getDate(element) {
        var date;
        try {
          date = $.datepicker.parseDate(dateFormat, element.value);
        } catch (error) {
          alert(error);
        }
        return date;
      }
    });
about 4 years ago · Juan Pablo Isaza
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