fill in right-to-left input

Asked

Viewed 2,447 times

1

I need two input that I have in an app are filled from right to left...

one of the inputs is real value (R$) the other is value in milliliter (ml), I am using a jquery mask (a Maskmoney works right but not on mobile, so I opted for another mask jQuery.maskdinput) apparently works on mobile, but fills the input from left to right, unlike Maskmoney, and with that it is a blank spaces, or if not to fill a monetary value have to put 0 the left to have for example (R$ 09,00) to have nine real.

I believe that if I can fill in the input from right to left, the problem will be solved.

2 answers

3

Solution using text-align:

input {
  text-align: right;
}
<input type="text">

The solutions below using the attribute say should apply only to languages that are written from right to left (such as Arabic):

With HTML using the attribute dir='rtl' (right to left):

<input name="DinheiroQueEhBomEuNaoTenho" dir="rtl" />

With CSS through property direction.

The Direction property defines the direction in which the text is written.

Definition - Direction

Take an example:

input{
  direction: RTL;
}
<input name="DinheiroQueEhBomEuNaoTenho" />

  • I didn’t know @Caique this css attribute, but here it got a little strange, the cursor gets lost while typing... I’m in Chrome I don’t know if mozila happens same thing, I’ll test

  • In Mozilla works a little better... Thanks for the help!

1


Browser other questions tagged

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