The TMT Validator has built-in pattern for 14 different date formats. To create a new custom date format we will take advantage of the Validator's extensibility.
Rules for date validation are stored inside tmt.validator.datePatterns, a JavaScript object, acting as a container for both built-in and custom date validation patterns. In order to add our own, we can call the tmt.validator.createDatePattern function.
The tmt.validator.createDatePattern() function requires 5 arguments:
The resulting JavaScript code is:
<script type="text/javascript">
tmt.validator.datePatterns["spacedate"] = tmt.validator.createDatePattern("^\([0-3]?[0-9]\)\\s\([0-2]?[0-9]\)\\s\([0-9]{4}\)$", 2, 1, 0, " ");
</script>
The XHTML code for the field looks like this:
<input type="text" name="mydate" tmt:datepattern="spacedate" />