Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

Help in autocompleting a sentence in a text field

Community Beginner ,
Mar 04, 2024 Mar 04, 2024

I'm trying to make a piece of javascript code that can read what's on the text field, and then auto complete to a much longer sentence.
So instead of typing in "Delivery Service, #555-6295" I would type in "D" and it would change itself to the full sentence but I'm having trouble figuring out how to do this.
Currently this is my code

Sky358535858ama_1-1709572986001.png

Would anybody be able to help?
Thank you

TOPICS
JavaScript , PDF
577
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Is it only "D" or it can be "d" too?

Try this as custom keystroke script:

if(event.change == "D")
event.change = "Delivery Service, #555-6295";

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Is it only "D" or it can be "d" too?

Try this as custom keystroke script:

if(event.change == "D")
event.change = "Delivery Service, #555-6295";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 04, 2024 Mar 04, 2024

That works beautifully! Thank you!
This should work fine, but would it be possible to make it a 2 letter keystroke?
I.E.
if(event.change == "DS")
event.change = "Delivery Service, #555-6295";
?
That way if something else needs to be entered starting with the letter D it won't autofill it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2024 Mar 04, 2024

No. The change is usually only one letter, unless you paste "DS" into the field, or type very quickly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 04, 2024 Mar 04, 2024
LATEST

Thank you very much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines