splitforms.com

Free tool / runs in your browser

Date regex tester: dd/mm/yyyy, mm/dd/yyyy and ISO

Choose a date format, test one value per line and copy the JavaScript regex or HTML pattern. Compare format checks with strict ranges and a leap-year aware ISO pattern before validating real calendar dates on your server.

^(?:(?!0000)[0-9]{4}-(?:(?:01|03|05|07|08|10|12)-(?:0[1-9]|[12][0-9]|3[01])|(?:04|06|09|11)-(?:0[1-9]|[12][0-9]|30)|02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$

Encodes Gregorian month lengths and the divisible-by-4, century and divisible-by-400 leap rules for years 0001-9999. Unlike the simpler format patterns, this rejects invalid February 29 dates. Still validate on the server with the easier-to-maintain isRealDate(y,m,d) round-trip helper below.

2 of 5 pass

  • Pass2024-02-29
  • Fail2023-02-29
  • Pass2000-02-29
  • Fail1900-02-29
  • Fail2026-04-31

Use the HTML pattern on type="text", with required for empty values. Browsers anchor it to the whole value. pattern does not apply to type="date".

All 8 date regex patterns

All formats require leading zeros. Range and calendar patterns use years 0001-9999. Passing a format-only pattern does not guarantee a real date.

FormatRegexPass / fail examplesNotes
ISO yyyy-mm-dd (format only)^[0-9]{4}-[0-9]{2}-[0-9]{2}$Pass: 2026-12-31, 2026-13-32
Fail: 31/12/2026, 2026-1-01
The shape input type=date sends to the backend, for four-digit years. Only checks digit counts and separators, so 2026-13-32 passes. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
dd/mm/yyyy^(?:0[1-9]|[12][0-9]|3[01])/(?:0[1-9]|1[0-2])/(?!0000)[0-9]{4}$Pass: 31/12/2026, 29/02/2024
Fail: 12/31/2026, 32/12/2026
Day first; requires leading zeros and bounds day to 01-31 and month to 01-12. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
mm/dd/yyyy^(?:0[1-9]|1[0-2])/(?:0[1-9]|[12][0-9]|3[01])/(?!0000)[0-9]{4}$Pass: 12/31/2026, 02/29/2024
Fail: 31/12/2026, 13/01/2026
Month first; requires leading zeros and bounds month to 01-12 and day to 01-31. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
dd-mm-yyyy^(?:0[1-9]|[12][0-9]|3[01])-(?:0[1-9]|1[0-2])-(?!0000)[0-9]{4}$Pass: 31-12-2026
Fail: 12-31-2026, 31/12/2026
Day first with hyphens and basic range checks. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
dd.mm.yyyy^(?:0[1-9]|[12][0-9]|3[01])\.(?:0[1-9]|1[0-2])\.(?!0000)[0-9]{4}$Pass: 31.12.2026
Fail: 31x12x2026, 12.31.2026
Dots are escaped to match literal dots. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
yyyy/mm/dd^(?!0000)[0-9]{4}/(?:0[1-9]|1[0-2])/(?:0[1-9]|[12][0-9]|3[01])$Pass: 2026/12/31
Fail: 2026/31/12, 2026-12-31
Year first with slashes and basic range checks. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
ISO strict ranges^(?!0000)[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$Pass: 2026-12-31, 2023-02-29
Fail: 2026-13-01, 2026-12-32, 0000-01-01
Rejects month 13 and day 32, but still accepts 2023-02-29. Years 0001-9999. A format regex can't fully check February 29 or month lengths; a JS Date round-trip check is needed. See isRealDate(y,m,d) below.
ISO leap-year aware^(?:(?!0000)[0-9]{4}-(?:(?:01|03|05|07|08|10|12)-(?:0[1-9]|[12][0-9]|3[01])|(?:04|06|09|11)-(?:0[1-9]|[12][0-9]|30)|02-(?:0[1-9]|1[0-9]|2[0-8]))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$Pass: 2024-02-29, 2000-02-29, 2026-12-31
Fail: 2023-02-29, 1900-02-29, 2100-02-29, 2026-04-31, 0000-01-01
Encodes Gregorian month lengths and the divisible-by-4, century and divisible-by-400 leap rules for years 0001-9999. Unlike the simpler format patterns, this rejects invalid February 29 dates. Still validate on the server with the easier-to-maintain isRealDate(y,m,d) round-trip helper below.

Regex vs <input type="date">

A populated native date input always submits YYYY-MM-DD whatever the user's locale, even when the picker displays day first or month first. These ISO patterns cover four-digit years; HTML also permits longer positive years. Use min and max for date bounds and required to prevent empty values.

date.html

<label for="date">Date</label>
<input id="date" name="date" type="date" min="2026-01-01" max="2026-12-31" required>

The pattern attribute applies to text fields, not date inputs. Use a text input only when you need an explicit format such as dd/mm/yyyy, with a clear label and format hint. Regex checks text; the native date control also checks calendar validity.

See the HTML Standard date input specification for native date behavior.

Validate the date on the server too

A format regex can't fully check February 29. Even the strict range pattern accepts 2023-02-29 and April 31. A JS Date round-trip check is needed after matching the expected format: JavaScript normalizes impossible dates, so compare the resulting year, month and day to the originals.

validate-date.js

function isRealDate(y, m, d) {
  if (![y, m, d].every(Number.isInteger) || y < 1 || y > 9999) return false;
  const date = new Date(0);
  date.setUTCFullYear(y, m - 1, d);
  return date.getUTCFullYear() === y &&
    date.getUTCMonth() === m - 1 && date.getUTCDate() === d;
}

// Match the expected format before converting the components.
const match = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(value);
const valid = match !== null && isRealDate(...match.slice(1).map(Number));

The leap-year aware ISO regex encodes Gregorian calendar rules, including centuries divisible by 400. The helper expresses calendar validation more clearly. UTC components avoid daylight-saving changes, and setUTCFullYear preserves years below 100. For slash formats, extract the components in the order you selected; do not rely on new Date(value) to guess a locale. Reject invalid values before storing them, then check permitted ranges and business rules on the server.

Date regex FAQ

What regex matches dd/mm/yyyy?

Use ^(?:0[1-9]|[12][0-9]|3[01])/(?:0[1-9]|1[0-2])/(?!0000)[0-9]{4}$. It accepts 31/12/2026 and rejects 12/31/2026, but still needs a calendar check for month lengths and February 29.

What regex matches mm/dd/yyyy?

Put the month first: ^(?:0[1-9]|1[0-2])/(?:0[1-9]|[12][0-9]|3[01])/(?!0000)[0-9]{4}$. It accepts 12/31/2026. Always choose the expected format explicitly: 03/04/2026 is ambiguous.

Can a date regex validate leap years?

A simple format or range regex cannot. The leap-year aware ISO pattern here encodes the full Gregorian rules: 2024-02-29 and 2000-02-29 pass; 2023-02-29 and 1900-02-29 fail. A Date round-trip check is easier to maintain on the server.

What format does input type=date submit?

A non-empty date value submits as YYYY-MM-DD regardless of the user's locale. The displayed date may look different. The HTML pattern attribute does not apply to type=date; use min and max for date bounds.

Should I validate dates on the server too?

Yes. Browser validation can be bypassed. Check the expected string format, parse year, month and day explicitly, and round-trip the components through a Date. Then enforce your allowed date range and business rules.

Date and time fields

Need a time as well? See input type=datetime-local for local date and time values without a time zone.

More free form tools

Form backend cost calculator

Enter monthly submissions and compare the cheapest listed plan across eight form backends.

Email deliverability checker

Enter a domain to check its SPF, DMARC and MX records and get a plain-English fix for each.

SPF record checker

Look up a domain's SPF record, see each mechanism explained and count DNS lookups against the 10-lookup limit.

DMARC record generator

Pick a policy and report address and copy a ready _dmarc TXT record.

DMARC checker

Look up a domain's DMARC record and see the policy and every tag explained.

DKIM record checker

Enter a domain and selector to check its DKIM key, with presets for common senders.

SPF record generator

Tick your email providers and copy one SPF TXT record with a lookup count.

Contact form spam checker

Paste form HTML to audit its honeypot, endpoint, CAPTCHA markers and spam resistance.

Honeypot field generator

Generate a hidden anti-spam input with your chosen name and hiding technique.

Form action URL tester

Check a form action URL for reachability, CORS headers, POST acceptance and backend.

Email obfuscator

Encode your email so spam scrapers can't read it but people can still click it.

Mailto link generator

Build a mailto: URL with recipients, CC, BCC, subject and a pre-filled body.

HMAC-SHA256 generator

Generate and verify webhook signatures for common providers in your browser.

URL encoder and decoder

Encode text, build an x-www-form-urlencoded body or parse a query string.

UTM builder

Build campaign URLs with UTM parameters, tag a CSV in bulk and check tagged links.

HTML to JSX converter

Paste HTML and get JSX or a working React/Next.js form component.

Image to Base64 converter

Convert images to Base64 data URLs in your browser and copy HTML and CSS snippets.

Base64 to image converter

Paste a Base64 data URI to preview and download the decoded image.

Base64 decode & encode

Decode Base64 to readable UTF-8 text or encode text to Base64, locally in your browser.

URL to Base64 converter

Fetch a direct image URL in your browser and get its Base64 data URL.

AI form generator

Describe your form in plain English and copy working HTML.

See all free tools