How to force UPPERCASE letters?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
spizpan
Posts: 9
Joined: 2020-06-21 22:48
Location: Greece

How to force UPPERCASE letters?

Post by spizpan » 2020-08-11 18:58

Hi! I have searched the entier forum for this issue, but haven't found anything letaded... So the question is:

While someone is typing and inserting data through the form fields, how can i force the conversion to UPPERCASE letters?

Any assistance will be appreciated

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to force UPPERCASE letters?

Post by pbottcher » 2020-08-11 20:41

Hi,

you can change the data in the hooks. Use the before_insert and before_update functions and use something like:

$data['YOURFIELDNAME']=strtoupper($data['YOURFIELDNAME']);
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: How to force UPPERCASE letters?

Post by D Oliveira » 2020-08-12 02:01

another option on tablename_dv.js use javascript on change function .toUpperCase();

https://www.w3schools.com/jsref/jsref_touppercase.asp

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to force UPPERCASE letters?

Post by zibrahim » 2020-08-13 02:52

As mentioned by D Oliveira, I use javascript in my TABLENAME-dv.js file in the hooks directory.
Create a new file and change the TABLENAME to yours.
Put the following code and don't forget to change the FIELDNAME to match with yours.

Code: Select all

// Set input to automatically convert to Uppercase. File hooks/tablename-dv.js
$j('#FIELDNAME').keyup(function () {
    $j(this).val($j(this).val().toUpperCase());
});
Good luck.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

spizpan
Posts: 9
Joined: 2020-06-21 22:48
Location: Greece

Re: How to force UPPERCASE letters?

Post by spizpan » 2020-08-13 20:03

Thanks a lot guys for your replies.

So i use the code below, in my tablename-dv.js file, as mentioned by zibrahim

Code: Select all

// Set input to automatically convert to Uppercase.
$j('my_field_name').keyup(function () {
    $j(this).val($j(this).val().toUpperCase());
});
but it doesn't seem to work. am i missing something?

Regards
Spiros

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to force UPPERCASE letters?

Post by zibrahim » 2020-08-13 23:33

Hi Spiros
Can I know the tablename and the fieldname that you are using for this issue?
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to force UPPERCASE letters?

Post by zibrahim » 2020-08-13 23:47

By the way,
I noticed that there is no # character before your FIELDNAME in your code. Perhaps that is the reason?
It should be

Code: Select all

$j('#my_field_name').keyup(function () {
    $j(this).val($j(this).val().toUpperCase());
});
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

spizpan
Posts: 9
Joined: 2020-06-21 22:48
Location: Greece

Re: How to force UPPERCASE letters?

Post by spizpan » 2020-08-14 17:58

zibrahim wrote:
2020-08-13 23:47
By the way,
I noticed that there is no # character before your FIELDNAME in your code. Perhaps that is the reason?
It should be
Hi Zibrahim,

Yes i was missing the # character as i thought it was an example character. I incuded the # character before the fieldname and again it did not to work....

BUT, the clue for me was to insert the code on the top of TABLENAME-dv.js !!! As long as i had the code at the end of this file, the code did not respond. Now it does :)

Thanks a lot for your help mate!

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: How to force UPPERCASE letters?

Post by aarlauskas » 2020-11-01 18:52

Thanks Ibrahim, very simple solution and very handy! Thank You!

yonder
Posts: 28
Joined: 2018-05-01 12:19

Re: How to force UPPERCASE letters?

Post by yonder » 2023-10-02 07:26

zibrahim wrote:
2020-08-13 02:52
As mentioned by D Oliveira, I use javascript in my TABLENAME-dv.js file in the hooks directory.
Create a new file and change the TABLENAME to yours.
Put the following code and don't forget to change the FIELDNAME to match with yours.

Code: Select all

// Set input to automatically convert to Uppercase. File hooks/tablename-dv.js
$j('#FIELDNAME').keyup(function () {
    $j(this).val($j(this).val().toUpperCase());
});
Good luck.
Hi zibrahim,

When i use that code it's working. However if i edit a record (for example the field is "name") and it has "Onder", i want to change the "n" and "d" characters, when i write "r" instead of "d" the cursor is going to end of the field. Is there a way to blocking it?

Best regards.

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to force UPPERCASE letters?

Post by zibrahim » 2023-10-02 10:49

Hi there Yonder,
try this

Code: Select all

// Set input to automatically convert to Uppercase while maintaining cursor position
$j('#FIELDNAME').keyup(function () {
    const startPos = (this).selectionStart;
    const endPos = (this).selectionEnd;
    (this).value = (this).value.toUpperCase();
    (this).setSelectionRange(startPos, endPos);
});
I found this in the internet
https://stackoverflow.com/questions/542 ... f-the-text

Have a nice day.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

yonder
Posts: 28
Joined: 2018-05-01 12:19

Re: How to force UPPERCASE letters?

Post by yonder » 2023-10-02 16:49

zibrahim wrote:
2023-10-02 10:49
Hi there Yonder,
try this

Code: Select all

// Set input to automatically convert to Uppercase while maintaining cursor position
$j('#FIELDNAME').keyup(function () {
    const startPos = (this).selectionStart;
    const endPos = (this).selectionEnd;
    (this).value = (this).value.toUpperCase();
    (this).setSelectionRange(startPos, endPos);
});
I found this in the internet
https://stackoverflow.com/questions/542 ... f-the-text

Have a nice day.
zibrahim wrote:
2020-08-13 02:52
As mentioned by D Oliveira, I use javascript in my TABLENAME-dv.js file in the hooks directory.
Create a new file and change the TABLENAME to yours.
Put the following code and don't forget to change the FIELDNAME to match with yours.

Code: Select all

// Set input to automatically convert to Uppercase. File hooks/tablename-dv.js
$j('#FIELDNAME').keyup(function () {
    $j(this).val($j(this).val().toUpperCase());
});
Good luck.

Hi zibrahim,

Yes it's working thanks. However i want to use the Turkish characters. If i use "ğüşöç" characters it can change to "ĞÜŞÖÇ" characters, but if i use "i" character it change it to "I" not "İ".

I was use the following code before your answer;

Code: Select all

$j('#pozisyon').keyup(function () {
    $j(this).val($j(this).val().toLocaleUpperCase('tr-TR'));
So how can i use your code with "toLocaleUpperCase('tr-TR)" or how can i use your code with Turkish "Ä°" character?

Thank you so much.

yonder
Posts: 28
Joined: 2018-05-01 12:19

Re: How to force UPPERCASE letters?

Post by yonder » 2023-10-02 16:56

Hello again,

Sorry, i just found the solution :)

Code: Select all

$j('#FIELDNAME').keyup(function () {
    const startPos = (this).selectionStart;
    const endPos = (this).selectionEnd;
    (this).value = (this).value.toLocaleUpperCase('tr-TR');
    (this).setSelectionRange(startPos, endPos);
});
Now it's working. Thank you so much again zibrahim.

Post Reply