How to disable using CSS or html automatic shift of the cursor to the beginning in the text field, if the field is updated and there is text in it? Those. There is a table search in a web application that works through ajax and does not require pressing a button. Implemented using java wicket. When I enter text in the field, after entering each character, the cursor jumps to the beginning and thus does not allow to enter text normally. What offer? Thanks.
1 answer
I suppose somewhere the cunning setText () method is used for the input field. And it is used to filter input, probably, or something like that.
I suggest that in the implementation of the input field after filtering is completed and the value is set to move the cursor to a position equal to the length of the text.
Maybe here or here you will find a solution on pure html and css, on js it is described above.
On JS, the function will look something like this:
document.getElementById("btn").addEventListener("click", function(){ var input = document.querySelector("input"); var len = input.value.length; input.setSelectionRange(len,len); input.focus(); }); For such a mold:
<input value="Lorem Ipsum"> <input id="btn" type="button" value="OK"> |