I am trying to get the .match() or .test() function to work with a 'Regular Expression'
Through some web searches for Date Validation, I found the Regular Expression to use for MMDDYYYY Date Validation:
//match date in format MM/DD/YYYY
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
And those same searches say to use this Regular Expression in a .match() or .test() to validate the Date
For preliminary testing, I have tried:
What is your date of birth?
<input type="text" id="input-dob" class="medium" placeholder="MM/DD/YYYY" name="lead-dob"/><label for="lead-dob" style="padding-left:8px">MM/DD/YYYY</label>
Then in the associated bound FocusOut code I have
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
var chkDate = $(event.currentTarget).val()
// The chkDate value is confirmed via an alert() to be good here
// But when I try to check this value...
alert(dateMMDDYYYYRegex.test(chkDate));
I get a Firebug error message dateMMDDYYYYRegex.test is not a function
And I tried
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
var chkDate = $(event.currentTarget).val()
// The chkDate value is confirmed via an alert() to be good here
// But when I try to check this value...
alert(chkDate.match(dateMMDDYYYYRegex));
I get a Firebug error message chkDate.match is not a function
Any suggestions and/or advice as to what I am doing wrong?
Thanks,
JRB-Bldr
Through some web searches for Date Validation, I found the Regular Expression to use for MMDDYYYY Date Validation:
//match date in format MM/DD/YYYY
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
And those same searches say to use this Regular Expression in a .match() or .test() to validate the Date
For preliminary testing, I have tried:
What is your date of birth?
<input type="text" id="input-dob" class="medium" placeholder="MM/DD/YYYY" name="lead-dob"/><label for="lead-dob" style="padding-left:8px">MM/DD/YYYY</label>
Then in the associated bound FocusOut code I have
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
var chkDate = $(event.currentTarget).val()
// The chkDate value is confirmed via an alert() to be good here
// But when I try to check this value...
alert(dateMMDDYYYYRegex.test(chkDate));
I get a Firebug error message dateMMDDYYYYRegex.test is not a function
And I tried
var dateMMDDYYYYRegex = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$';
var chkDate = $(event.currentTarget).val()
// The chkDate value is confirmed via an alert() to be good here
// But when I try to check this value...
alert(chkDate.match(dateMMDDYYYYRegex));
I get a Firebug error message chkDate.match is not a function
Any suggestions and/or advice as to what I am doing wrong?
Thanks,
JRB-Bldr