Simba
Simba

Reputation: 1

How to make the cursor blinking visible in a text box while its value is manipulated via JS function called onfocus

In a form I have a textbox which should have a currency value. I have a requirement to show the currency in the format 234,345,456 and if the user want to edit, then I need to show only the digits and not the coma in between the digits. So I written one function which will remove the coma and set its value with only digits. I am calling this function on onfocus event. Its perfectly working, but the only problem is when I traversed to that text box using tab key of the keyboard, then the blinking cursor doesn't appear, so the user is not understanding whether the focus is there in that text box or not. So how to show the blinking cursor onfocus?

Upvotes: 0

Views: 887

Answers (2)

Muhammad Umer
Muhammad Umer

Reputation: 2308

Hi

Look into Dispatch Event on mdn.

Upvotes: 0

The King
The King

Reputation: 11

If you are changing text it won't show the cursor, but you can change the background when textbox is focused through JavaScript like below:

box.style.backgroundColor = 'HighlightText';

Upvotes: 1

Related Questions