1. Gzim Ramizi
  2. PowerBuilder
  3. Tuesday, 7 November 2023 13:35 PM UTC

Hi all,

is there a way how one could suppress a certain character for datawindow fields?

I have a field where I should allow just numbers (0-9) and letters (a-z, A-Z); if the user types something else, like spacebar or any other signs, the entry should just be suppressed (during the entry..., it should behave like didnt happen anything)..., without any messages, I tried smth over the key-event, but it doesnt work :(

//suppress space(?) - doesnt work!
if this.getcolumnname( ) = "reise_flugnummer" and key = keyspacebar! then return 1

 

I am on PB2021 1506 and Win 11.

TIA,
gzim

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 7 November 2023 13:51 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi.

You can set the edit style type to editmask. Then you set the mask. Example: if the user should fill the field with up to 20 alphanumeric characters [0-9], [a-z] or [A-Z] set the mask to "aaaaaaaaaaaaaaaaaaaa".

Andreas.

Comment
  1. Gzim Ramizi
  2. Tuesday, 7 November 2023 14:02 PM UTC
but this allows either one or the other, not both at the same time, i.e. both numbers and letters....? It should be able to enter "A1B2C34".
  1. Helpful
  1. Gzim Ramizi
  2. Tuesday, 7 November 2023 14:07 PM UTC
Sorry for my previous comment...now I get it...i was supposed just to use the amount of a's for my case...and a allows both, numbers and letters. Thank you!
  1. Helpful 2
  1. Gzim Ramizi
  2. Tuesday, 7 November 2023 14:58 PM UTC
additional question: is there a way how to limit just uppercase? :-) I tried "!a!a", but this allows 4 characters ... :-/
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 7 November 2023 15:24 PM UTC
  2. PowerBuilder
  3. # 1

"!" doesn't work in combination with "a". You should replace the "aaa.." with "!!!...". But this will allow also other characters (like space). What you can do is to let the user fill the field and put some script in editchanged event of your datawindow:

if dwo.name = "a1" then
	this.object.a1[row] = upper(data)
	this.selecttext(len(data) + 1, 1)
end if

But be careful, as this may have different behavior than what you need.

In my opinion it would be better to execute uppercase when dataentry of this field is complete (itemchanged). The issue with that is that the characters will turn to uppercase at the end.

Andreas.

Comment
  1. Gzim Ramizi
  2. Tuesday, 7 November 2023 15:36 PM UTC
Thank you so much. You are right. I will negotiate it with my req.eng.
  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.