latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Custom Fields – Format Checking

Home Forums Community Forum Unofficial Extensions/Hacks Custom Fields – Format Checking

This topic contains 2 replies, has 3 voices. Last updated by  Cristián Lávaque 4 years, 2 months ago.

Topic Author Topic
Posted: Saturday Oct 20th, 2012 at 12:33 am #29098

Just came across this when using the specific format “Date” within custom field creation:

The JS regex that validates the format is this:

(/^[0-9]{2}/[0-9]{2}/[0-9]{4}$/)

This doesn’t check for a valid date according to the dd/mm/yyyy format stated, rather it checks for any 2 digits separated by forward slashes (with any 4 digits on the end).

In order to have the format validated for a real date I’ve updated my regex to:

(/^(0[1-9]|1[1-2])/([0-2][1-9]|3[0-1])/(19|20)[0-9]{2}$/)

(I’ve changed mine to be mm/dd/yyyy format, with the year having to be within the 20th or 21st century)

Not perfect, but at least it guarantees I get a date in mm/dd/yyyy format.

  • This topic was modified 4 years, 2 months ago by  Cristián Lávaque.
  • This topic was modified 3 years, 4 months ago by  Iron Phoenix.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Monday Oct 22nd, 2012 at 1:13 pm #29281
Raam Dev
Username: Raam
Staff Member

Thank you for sharing that!

Awarded the Helpful badge.
Posted: Monday Oct 22nd, 2012 at 10:52 pm #29356

Thanks! :)

I’m moving this to the user hacks forum. http://www.s2member.com/forums/forum/community/extensions-hacks/

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.