In general programs, programmers generally like to determine the focus box by judging the legality of the content when checking the correctness of the content of the input box.
For example:
That is, after obj.focus() moves the focus to the input box, it will move the text cursor (that is, the flashing vertical line) to the position of the first character of the input box... Just above In terms of judgment...if there is no content in the text box...obj.focus can just allow us to enter content directly in the text box without clicking the text box to make the text focus...
However, if there is already content in the text box... but this content is illegal. obj.focus() also moves the cursor to the position of the first character of the text box... At this time, attention will be drawn The user experience designer is frustrated... What we need is that the text box gets focus, and then the text cursor moves to the end of the text box, so that the user can enter content directly without clicking the text box. The input content will be in the original content. Add them later...
The following code can complete this small detail: