1. Paweł Kasperek
  2. PowerBuilder
  3. Thursday, 25 January 2024 14:41 PM UTC

Hi,

 

I've DataWindow with EditMask fields. I know how to set numerical masks with # chars. But the '####' mask ignores multiple 0 chars on lead. I can trim 0 chars on lead ex. 000754 to 754. Is possible to set a mask to block entry 0 char before the number?

PS.

I use latest PowerBuilder 2022 R3.

 

Regards,

Pawel

 

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 25 January 2024 16:19 PM UTC
  2. PowerBuilder
  3. # 1

Hi Paweł;

  Here are the ways that I would enforce this Zero entry to be rejected ...

  • Use a Validation Rule (via the DB painter or add via the DW Painter) to reject any Leading Zeros..
  • Add code to the EditChanged event of the DC to enforce that rule under PowerScript control

HTH

Regards ... Chris

 

Comment
  1. Paweł Kasperek
  2. Friday, 26 January 2024 06:35 AM UTC
Hi Chris,



I've implemented of EditChanged event, but I'm looking for a better solution. Maybe in the future, we will add a regex pattern to the validation edit mask.

  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 26 January 2024 16:04 PM UTC
Yes, the EditChanged is probably the way I would have handled this as well.

Another trick I use sometimes is calling a Global Function to handle common edits across columns requiring the same restrictions and thus, need to only code this checking once but then it's reusable. ;-)
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 26 January 2024 03:30 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Pawel -

I believe if the column has a numeric data type (such as long, for example), then the edit mask will not allow a leading zero to be entered. My guess is your column has a data type of string, and a character of "0" is certainly a valid string character... so it allows one or more leading zeroes.

Best regards, John

Comment
  1. Paweł Kasperek
  2. Friday, 26 January 2024 06:34 AM UTC
Hi John,



Yep, the field is string type :(. I know that in this situation '0' as lead chars is normal situation.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.