Hi,
Is there a way to disallow characters typing into date/time field?
Thanks!
Views
Replies
Total Likes
One way would be to declare the date-time value as "Calculated - Read Only" and select a runtime property as current date. Depending on your objectives you could declare the value as "Protected" or "Read Only" also.
Steve
Views
Replies
Total Likes
Hi Steve,
I didn't explained myself well.
The goal is not to make field read only but to disallow users to type any
characters beside numeric.
Is that possible ?
-Yan.
Views
Replies
Total Likes
Yan,
Date fields are inherently alphanumeric. You could use a simple numeric field with a display and validation pattern of num{99999999}. I am a programmer by trade so I like to write code. I find text fields easier to manipulate. For example, for a text field with a max length of 8...
// form1.page1.subform1.date_::exit - (JavaScript, client)
if (!(this.isNull || this.rawValue == "")) {
var str = this.rawValue;
var regExp = /\D/;
if (regExp.test(str)) {
xfa.host.messageBox("Date must contain digits only.");
}
else {
if (str.length != 8) {
xfa.host.messageBox("Date must contain 8 digits (MMDDYYYY).");
}
}
}
This forces 8 digits. If you want to validate MM, DD and YYYY plan accordingly.
Steve
Views
Replies
Total Likes
Hey Steve, quick question, I thought if you used the .isNull test you didn't need to also do the =="" ? Or does checking for "" do something different?
According to John Brinkman the two ways to test for null are: "field.rawValue === null" or "field.isNull".
I keep seeing different variations and want to make sure I'm doing it the correct way.
Views
Replies
Total Likes
Views
Likes
Replies