meganbabb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-24 03:54 UTC
Text Input Right to Left
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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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, meganbabb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <meganbabb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 24 Dec 2007, at 04:54, meganbabb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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?http://zend.lojcomm.com.br/iMask/ Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---