Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!