Can someone please, if possible make it clear what is the correct regExpTime that will do validation for a time field and allow client to enter any time format as is KK:MM format like 10:00, 12:00, 24:00 or 12:22, 10:23 but prevent them from entering garbage and letters.
What I have now is the following code on the exit event and
display pattern set to time{KK:MM} and edit pattern set to time{KK:MM}|time{KKMM}|time{KK MM}|time{KK-MM}|time{KK.MM.SS}|time{KK.MM}|time{KK,MM},
still my time field does not accept any time > 9:00. It will however accept 10:22, 11:29 but not 10:00 or 11:00 …etc
var vMatched = this.rawValue.match(regExpTime);
if (!vMatched){
this.rawValue
=null;
xfa.host.messageBox("Please time format - HH:MM. "
, "Message", 3, 0);
xfa.host.setFocus(
this);
}
Thank you!
Views
Replies
Total Likes
The following exp would not work either...
var regExpTime = /^\d{1,2}[:]\d{2}([:]\d{2})$/;
Views
Replies
Total Likes
In case anyone else runs into the same issue...The working solution
is :
if
(!(this.isNull)) {
var time_ = this.rawValue;
if (time_.length != 5) {
xfa.host.messageBox("Please enter correct time format - HH:MM. "
, "msg", 3, 0);
this.rawValue
= "";
xfa.host.setFocus(
this);
}
else {
var regExp = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
if (!(regExp.test(time_))) {
xfa.host.messageBox("Please enter correct time format - HH:MM. "
, "msg", 3, 0);
this.rawValue
= "";
xfa.host.setFocus(
this);
}
}
}
Views
Replies
Total Likes