Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Date dd mm yyyy

Omar Shammas edited this page Sep 13, 2013 · 1 revision

Formats the date in the dd / mm / yyyy format:

  • Limits to 8 numbers
  • Restricts input to numbers or slashes depending on the current state
  • Includes a / between the day & month and month & year.
  • Does NOT accept shorthand to avoid ambiguities
$('input.dd_mm_yyyy').formance('format_dd_mm_yyyy');

Validates the date:

  • Validates the date can be parsed.
  • Validates the date actually exists so it will fail if February 30th is entered even though it passes parsing.
$('input.dd_mm_yyyy').formance('validate_dd_mm_yyyy');

Date includes a helper function to retrieve the date value. Note it does not check to see if it is valid. It simply creates a date object with the specified values which may be incorrect. For example new Date(2013, 2-1, 30) returns March 2nd because February does not have 30 days. You should check if it is valid before using the date.

If the text is parsed without any errors then a Javascript Date object is returned otherwise false.

$("<input value='01 / 07 / 2013' />").formance('val_dd_mm_yyyy');   // new Date(2013, 7-1, 1)
$("<input value='dd / 07 / 2013' />").formance('val_dd_mm_yyyy');   // false 

Clone this wiki locally