Text input text box on the right

3

In a box that the text is aligned to the right, how do I do that when I focus on the text box independent of the place the writing cursor goes right?

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

    
asked by anonymous 14.02.2014 / 13:20

2 answers

3

I found the answer to another question in Stack Overflow. See if it serves:

link

$('#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();
    }
});
    
14.02.2014 / 13:33
0

Try the following:

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

function ltr (el)
{   
    if (el.setSelectionRange) {
        el.setSelectionRange(0,0);
    }
}
    
14.02.2014 / 13:31