Text input box on the right

Asked

Viewed 921 times

3

In a box the text is aligned to the right, as I do so that when focusing the text box regardless of the place the writing cursor goes to the right?

I want that when clicking an input of type text where is inserted a decimal value the courses always go to the last character on the right

  • 1

    If the field is aligned to the right, the cursor is always to the right. I’m not understanding the question, can you give an example?

  • I don’t understand the question. Do you want to put a text box to the right when it is already on the right? That’s what I understood

  • the field is decimal value input, when the user click in the middle of the value for example before the comma I want the write cursor go to the end of the right corner

  • You want to click on an input of the type text where a decimal value is inserted the strokes always go to the last character on the right. that’s it?

  • @Erloncharles

2 answers

3


I found the answer in another question in the Stack Overflow (in English). See if it fits:

https://stackoverflow.com/questions/7368750/how-to-set-the-cursor-position-at-the-end-of-a-string-in-a-text-field-using-jque

$('#foo').focus(function() {
    if (this.setSelectionRange) {
        this.setSelectionRange(this.value.length, this.value.length);
    } else if (this.createTextRange) {
        // internet explorer
        var range = this.createTextRange();
        range.collapse(true);
        range.moveStart('character', this.value.length);
        range.moveEnd('character', this.value.length);
        range.select();
    }
});
  • Even if the answer isn’t yours I’ll give you a certain, because you brought her to me

  • I saw that too, but I tested it and it didn’t work - http://jsfiddle.net/8xWtb/

0

Try the following:

<input type="text" onkeyup="ltr(this)" />

function ltr (el)
{   
    if (el.setSelectionRange) {
        el.setSelectionRange(0,0);
    }
}
  • This is a parameter for the direction of the text in the input to be right-to-left. What the user wants is for the text cursor to go to the right, but the direction of the text remains left-to-right.

  • That’s right, but I wanted him to go right

Browser other questions tagged

You are not signed in. Login or sign up in order to post.