CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Use Regular Expression for data input

by MicroSolutions » 05 Jun 2019 16:33

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
MicroSolutions
 
Posts: 49
Joined: 22 Feb 2016 11:53

by Alexander Bulei » 07 Jun 2019 17:12

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.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by MicroSolutions » 17 Jun 2019 14:00

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
MicroSolutions
 
Posts: 49
Joined: 22 Feb 2016 11:53

by Alexander Bulei » 19 Jun 2019 09:24

Hi MicroSolutions,

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

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by MicroSolutions » 21 Jun 2019 11:55

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
MicroSolutions
 
Posts: 49
Joined: 22 Feb 2016 11:53

by Alexander Bulei » 28 Jun 2019 09:46

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.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to JQEdit

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.