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

Help in autocompleting a sentence in a text field

Community Beginner ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

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

Views

153

Translate

Translate

Report

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

correct answers 1 Correct answer

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";

Votes

Translate

Translate
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Copy link to clipboard

Copied

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";

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you very much!

Votes

Translate

Translate

Report

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