//If you want a date of type yyy-mm-dd const date_check = /^d{4}-d{2}-d{2}$/; let check = date.match(data_check) if(check1 == null) alert('invalid date');