Hello everybody!
I have a challenge that to me seems a bit tricky. I have a text field that appears as a comb of 11 characters. The user will enter digits in the format 999999-9999. Now I would like to check if the firs 6 digits are a valid date in the format ddmmyy. (the last 4 digits are random)
How can I do that?
Kirstine
Solved! Go to Solution.
Views
Replies
Total Likes
Topics help categorize Community content and increase your ability to discover relevant content.
This needs to be tested THOROUGHLY. My testing was very limited. Given a two digit year the validation checks for two digits (\d\d) only.
// form1.page1.subform1.tf1::exit - (JavaScript, client)
if (!(this.isNull)) {
var regEx = /^(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[012])\d\d$/;
var str = this.rawValue;
str = str.substring(0,6);
if (regEx.test(str)) {
xfa.host.messageBox("Valid mmddyy");
}
else {
xfa.host.messageBox("Invalid mmddyy");
}
}
Steve
Views
Replies
Total Likes
Validate them using Regular Expression.
Nith
Views
Replies
Total Likes
This needs to be tested THOROUGHLY. My testing was very limited. Given a two digit year the validation checks for two digits (\d\d) only.
// form1.page1.subform1.tf1::exit - (JavaScript, client)
if (!(this.isNull)) {
var regEx = /^(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[012])\d\d$/;
var str = this.rawValue;
str = str.substring(0,6);
if (regEx.test(str)) {
xfa.host.messageBox("Valid mmddyy");
}
else {
xfa.host.messageBox("Invalid mmddyy");
}
}
Steve
Views
Replies
Total Likes
Hi Steve
Your script seams to do the job. Thanks a lot.
And to Nith,
Your point is all right. I just need more help than that as I’m a total newbie when it comes to scripting (any scripts at all) and I’m still not able to build my own scripts from scratch. It will come some day, I hope.
Regards,
Kirstine
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies