I am using below code to create date object after accepting date string from user in MM/DD/YYYY string format.
var userEnteredDate = '02/31/2015'; //example incorrect date entered by user
var userDate = new Date(userEnteredDate); //Getting rounded to 3rd March instead of throwing error
Is there any way to fix this in JavaScript. I would not like to do all the validations for Leap years, Date missing from Gregorian Calendar etc.
The required behavior is it should return NaN when passing wrong date. I do not want to use any third party library for compatibility reason with older version of angularjs.
**Note:**This is different than using Momentjs, this question is about the issue in javascript date functionality