validate MMDDYYYY format using Moment
You can have the expected output using last vesion (2.24.0), instead of the old 2.2.1.
Here a live sample:
var dates = "08291975";
var passed = moment(dates, 'MMDDYYYY', true).isValid();
console.log('should pass ' + passed);
dates = "082919751"; //one extra digit
passed = moment(dates, 'MMDDYYYY', true).isValid();
console.log('should not pass ' + passed);
dates = "0829ssss";
passed = moment(dates, 'MMDDYYYY', true).isValid();
console.log('should not pass ' + passed);
dates = "0829197"; //one digit missing
passed = moment(dates, 'MMDDYYYY', true).isValid();
console.log('should not pass ' + passed);
<script src="https://rawgit.com/moment/moment/2.24.0/min/moment.min.js"></script>