TGrif
TGrif

Reputation: 5931

Selected value in javascript prompt

I'm waiting for user input like this:

prompt('hello', 'world');

I don't understand why my prompt defaultText 'world' is selected.

Not a big deal, just curious, but I'd like to focus on first character without selection.
Is there some kind of placeholder for javascript prompt box or a way to do it (in pure javascript) ?

Upvotes: 1

Views: 419

Answers (2)

Shahdat
Shahdat

Reputation: 5483

prompt(text,defaultText)

The default input text shown as selected to save user time to override it easily. All browsers are doing same except Safari.

Upvotes: 0

Madara's Ghost
Madara's Ghost

Reputation: 174957

Well, it's a UX feature. The default is "world" but if I wanted to override it, I can just start typing, it saves me from selecting all of it. If I wanted to append to it, all I need to do is press the left arrow.

Upvotes: 1

Related Questions