Expand my Community achievements bar.

SOLVED

regExp for the Time (KK:MM)

Avatar

Former Community Member

Below is regExp for a Date. Can someone please provide more information on what would be the right code for the Time.

Thank you,

var

regExpDate = /^\d{4}-\d{2}-\d{2}$/;

var

vMatched = this.rawValue.match(regExpDate);

var

sDate = this.rawValue;

var

oDate = util.scand("yyyy-mm-dd", sDate);

if

((!vMatched)||(oDate == null)){

this.rawValue

=null;

xfa.host.setFocus(

this);

}

1 Accepted Solution

Avatar

Correct answer by
Level 6

Have you tried:

regExpTime = /^\d{1,2}\:\d{2}$/;


View solution in original post

3 Replies

Avatar

Correct answer by
Level 6

Have you tried:

regExpTime = /^\d{1,2}\:\d{2}$/;


Avatar

Former Community Member

I am missing something. With the code below, 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 format like 12:30 or 12:15. .

regExpTime

= /^\d{1,2}\:\d{2}$/;

var

vMatched = this.rawValue.match(regExpTime);

var

sTime = this.rawValue;

var

oTime = util.scand("HH:MM", sTime);

if

((!vMatched)||(oTime == null)){

this.rawValue

= null;

xfa.host.setFocus(

this);

}

Avatar

Former Community Member

var

regExpTime = /^\d{1,2}\:\d{2}$/;

var vMatched = this.rawValue.match(regExpTime);

if (!vMatched){

this.rawValue

=null;

xfa.host.messageBox("message")l

xfa.host.setFocus(

this);

}

It works. Thank you so much.