Page 1 of 1

Use Regular Expression for data input

PostPosted: 05 Jun 2019 16:33
by MicroSolutions
Dear CGDevTools team,

I would like to use RegEx for data input.
Is it possible with IWCGJQEdit.MaskExOptions property?

Can you send me a delphi exmple?

Thanks in advance!
MicroSolutions

Re: Use Regular Expression for data input

PostPosted: 07 Jun 2019 17:12
by Alexander Bulei
Hi MicroSolutions,
The jquery plugin what we use, is little old and don't have direct application of regex, but you can do it by creation of new definition and on ValidateFn.Script, you can write up your regex and test.

Best Regards.

Re: Use Regular Expression for data input

PostPosted: 17 Jun 2019 14:00
by MicroSolutions
Hello,

I inserted a small script in the ValidatorFn.Script, but it does not work.

My source is simple :
self.IWCGJQEdit7.MaskExOptions.Enable := True;
with IWCGJQEdit7.MaskExOptions.Definitions.add do
begin
ValidatorFn.Script := 'function (chrs, maskset, pos, strict, opts){ ' +
' return =new RegExp("^[0-9]{2}:[0-5][0-9]:[0-5][0-9]$").test(chrs);' +
' }';
end;

What else I have to do to use Regular Expression?

Thanks in advance!
MicroSolutions

Re: Use Regular Expression for data input

PostPosted: 19 Jun 2019 09:24
by Alexander Bulei
Hi MicroSolutions,

It's not enough, you need define the MaskChar in definition item, and then, use that char in input mask.

Best Regards.

Re: Use Regular Expression for data input

PostPosted: 21 Jun 2019 11:55
by MicroSolutions
Hello ,

it is not exactly clear for me.
I think the maskChar is a character to cover unfilled parts of the mask.
You wrote I have to use this character in the mask.
It looks like the following and it does not work:

self.IWCGJQEdit7.MaskExOptions.Enable := True;
self.IWCGJQEdit7.MaskExOptions.Mask := '99_99_99';

with IWCGJQEdit7.MaskExOptions.Definitions.add do
begin
MaskChar := '_';
ValidatorFn.Script := 'function (chrs, maskset, pos, strict, opts){ ' +
' return =new RegExp("^[0-9]{2}:[0-5][0-9]:[0-5][0-9]$").test(chrs);' +
' }';
end;

I have an other question: can I define a mask which allows only negative or positive duration?
How can build such a mask?

for example: "-122:12:01" or "45:45:66"



Best Regards:
MicroSolutions

Re: Use Regular Expression for data input

PostPosted: 28 Jun 2019 09:46
by Alexander Bulei
Hi MicroSolutions,

I think the maskChar is a character to cover unfilled parts of the mask.


No, its char identifier of mask

Anyway, I've detected some issues with usage of custom validator (ValidatorFn), which are fixed on next beta build.

Best Regards.