jQuery-Mask-Plugin icon indicating copy to clipboard operation
jQuery-Mask-Plugin copied to clipboard

Mask 00/00/0000 doesnt allow iOS autofill with birthdate

Open jstallm opened this issue 6 years ago • 1 comments

If you create a mask with '00/00/0000', iOS does not allow entering of birthdate from autofill.

Steps to reproduce. Add birthdate to your contact within your contact list Create form with mask '00/00/0000', attempt to autofill.

The field is invalid.

@igorescobar, Is there a way this is handled easily? Essentially what I want is to be able to insert a date such as 05/20/1980 or autofill with 5/20/1980

jstallm avatar Feb 19 '19 23:02 jstallm

Hi, You can add translation settings and add your first day and month digits as optional as this example:

$('#date_field').mask('AB/CB/DBBB', {
    translation: {
      A: { pattern: /[0-3]/, optional: true },
      B: { pattern: /\d/ },
      C: { pattern: /[0-1]/, optional: true },
      D: { pattern: /[1-2]/ },
    }
  });

sacerro avatar Dec 01 '21 11:12 sacerro