Date Validation Issue
I have an issue validating Date format: If I write '01/01-1987' I need to validate as a wrong format, it should only accept '01/01/1987' || '01-01-1987' || '01 01 1987'. How can I
Solution 1:
You can add 1 more test method for invalid date, like this one:
constisValidFormat = str => str.replace(/[^\/ -]/g, "")
.split('')
.every((e, _, a) => a[0] === e)
console.log('12-12-1994:', isValidFormat('12-12-1994'))
console.log('12/12-1994:', isValidFormat('12/12-1994'))
console.log('12-12 1994:', isValidFormat('12-12 1994'))
console.log('12/12/1994:', isValidFormat('12/12/1994'))
Post a Comment for "Date Validation Issue"