Hi everyone, I hope someone can help me on this. I've created the following date validation script for a date/time field that is set to run in a dynamic form. The issue I am having however is that it validates everything except whether or not the "/" is used as part of the date entry ie 28/02/2008. What I am trying to avoid is having the user enter a date using another type of symbol ie 28-02-2008. Any thoughts on how I should change my Regular Expression to address this issue?
(Please note I wish to keep the date validation as a java script using a regular express - to keep things focused I do realize there other ways of date validation). Thank you.
var myRegExp = /\d?\d\W\d?\d\W\d?\d?\d\d/;
var myDate = (this.rawValue);
var DD = parseFloat(this.formattedValue.substr(0,2));
var MM = parseFloat(this.formattedValue.substr(3,2));
var YYYY = parseFloat(this.formattedValue.substr(6,4));
var msg = "DATE FORMAT ERROR"
if (myDate == null);
else if(myRegExp.test(myDate) == true);
else if(myRegExp.test(myDate) == false && this.formattedValue.length == 10)
{app.alert(msg); this.rawValue = null}
if(DD > 31 || DD < 1)
{app.alert(msg); this.rawValue = null};
if (MM > 12 || MM < 1)
{app.alert(msg); this.rawValue = null};
if (YYYY > 2100 || YYYY < 1850)
{app.alert(msg); this.rawValue = null};
if (this.formattedValue.length != 0 && this.formattedValue.length != 10)
{app.alert(msg); this.rawValue = null};
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com