I am attempting to use jQuery to add a hashtag (#) after the user types and presses space. I have created a demonstration on CodePen.
In this demo, when you type something like (how are you
), the JavaScript code will change it to (#how #are #you
).
To achieve this, I am checking the words for adding the #(hashtag) tag using the function addHashtags(text) { ... }
.
1-) Everything works correctly for English characters. However, I want to extend this functionality to support multiple languages. The issue arises when typing Turkish characters like (üğşıöç
). For example, when I type the word (üzüm
) or (hüseyin
), the JavaScript should convert them to (#üzüm #hüseyin
) but instead, it adds extra symbols like this: (#ü#zü#m #hü#seyin
). (Issue Resolved)
2-) Another challenge is with other languages such as Arabic, Azerbaijan, Japanese, and so on. The JavaScript does not add the #(hashtag) tag when typing in these languages. For instance, typing (
私は家族と一緒に行きます
) or (ผมไปกับครอบครัวของฉัน
) does not trigger any changes. This is a significant problem that requires a solution. (Issue Resolved)
3-) In the demo, I have used textInput
. It works on mobile devices but not on Firefox. If I switch to using keypress
, the code functions on Firefox but not on mobile. I need the code to work seamlessly across all devices. (Issue Resolved)
// Your custom JS code goes here...