That's not a RTL input, it's just right-aligned :) (You still read the
values from LTR)

To format the numbers, I'd add a method in String.prototype

String.prototype.padAsFloat = function(precision) { // UNTESTED!
  var precision = precision || 2, number = parseInt(this.replace(/\./,
"")).toPaddedString(precision + 1), decimal, integer;
  decimal = number.substring(number.length - precision);
  integer = number.length > precision ? number.substring(0,
number.length - precision) : "0";
  return integer + "." + decimal;
}

Then you can capture the onkeydown event, get the pressed key, append
it to the current value, call padAsFloat on the string and then set
the input's value to the result. Or something along those lines :)

HTH,
-Nicolas


On Dec 24, 2007 1:54 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> How would one accomplish a text input that works similar to RTL input.
>
> For instance, if the text box starts with value of "0.00"; if the user
> hits 5 then the value is "0.05" and then if the user enter 23 then the
> value becomes "5.23".
>
> Any suggestions?
>
> Thanks.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to