Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript date Input mask MM/DD/YYYY
const maskDate = value => {
let v = value.replace(/\D/g,'').slice(0, 10);
if (v.length >= 5) {
return `${v.slice(0,2)}/${v.slice(2,4)}/${v.slice(4)}`;
}
else if (v.length >= 3) {
return `${v.slice(0,2)}/${v.slice(2)}`;
}
return v
}
@nabs32595

This comment has been minimized.

Copy link

@nabs32595 nabs32595 commented Jul 15, 2021

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment