Date handling does not work on Internet Explorer but does work on Chrome and FF

Date handling does not work on Internet Explorer but does work on Chrome and FF

In a symfony 4 project, I have a form element that works in Chrome and Firefox but not in Explorer and I can't see why. Rendering seems to be identical, so it has to be the way I'm handling the field on form submission, but again there's nothing obvious to me about why it does not work.

In a symfony 4 project, I have a form element that works in Chrome and Firefox but not in Explorer and I can't see why. Rendering seems to be identical, so it has to be the way I'm handling the field on form submission, but again there's nothing obvious to me about why it does not work.

My entity class:

class Person
{
    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $dob;

// ....

}

My form type:

class PersonFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('dob', DateType::class, [
                'label' => 'DOB (m/d/yyyy)',
                'widget' => 'single_text',
                'format' => 'M/d/yyyy',
                'attr' => ['autocomplete' => 'off', 'class' => 'js-dob'],
                'html5' => false,
            ]);
    }
}

and finally the javascript that processes on form submission:

$('.js-save-button').on('click', function() {
    // convert 2-digit years to 4-digit version in dob field
    $('.js-dob').each(function() {
        let date = new Date($(this).val());
        if (date instanceof Date && !isNaN(date)) {
            if (date > new Date()) {
                date.setFullYear(date.getFullYear() - 100);
            }
            $(this).val(date.toLocaleDateString("en-US"));
        }
    });
});

The javascript code is pretty self-explanatory, but the idea is that if the user enters a dob like June 1, 1923 as '6/1/23' then this would be converted to '6/1/1923' on form submission. As it stands all works fine in Chrome/FF, but on IE I get a form validation error from symfony with a message "This value is not valid." no matter how I enter the date.


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

JavaScript Tutorial: if-else Statement in JavaScript

This JavaScript tutorial is a step by step guide on JavaScript If Else Statements. Learn how to use If Else in javascript and also JavaScript If Else Statements. if-else Statement in JavaScript. JavaScript's conditional statements: if; if-else; nested-if; if-else-if. These statements allow you to control the flow of your program's execution based upon conditions known only during run time.

How to Retrieve full Profile of LinkedIn User using Javascript

I am trying to retrieve the full profile (especially job history and educational qualifications) of a linkedin user via the Javascript (Fetch LinkedIn Data Using JavaScript)