HTML5 pattern for formatting input box to take date mm/dd/yyyy?

后端 未结 6 2057
轻奢々
轻奢々 2020-12-28 15:25

I used jQuery datepicker and I want to restrict my input field with a HTML5 pattern if a user, instead of getting the date from jQuery datepicker, types the date.

H

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 15:53

    I've converted the http://html5pattern.com/Dates Full Date Validation (YYYY-MM-DD) to DD/MM/YYYY Brazilian format:

    pattern='(?:((?:0[1-9]|1[0-9]|2[0-9])\/(?:0[1-9]|1[0-2])|(?:30)\/(?!02)(?:0[1-9]|1[0-2])|31\/(?:0[13578]|1[02]))\/(?:19|20)[0-9]{2})'
    

提交回复
热议问题