hi, i'm running across a problem and want to alert the community about
it. i don't yet have a solution but am working on it. maybe one of you
has done it before.

what's happening the javascript that prevents you from putting bad
characters in the "double" input fields is also acting strangely in
safari and chrome.

the javascript in question is this (included in web2py code):
jQuery('input.double,input.decimal').keyup(function()
{this.value=this.value.reverse().replace(/[^0-9\-\.]|[\-](?=.)|[\.](?
=[0-9]*[\.])/g,'').reverse();});

and the issue is that when you call:
this.value=this.value.replace(/anything/,'anything')

it automatically puts the cursor at the end of the line. so if you put
your cursor at the end of the line and hit delete, everything looks
great. you go from 12.34| to 12.3| to 12.|, etc.

but in my case, where i'm using currency, people are likely to put
their cursor to the left of the decimal point to make a change. so
when they're at 25|.00 and they hit delete, it erases the proper
number but throws the cursor to the right so it looks like 2.00| and
causes problems. same if you use the arrow keys -- you get the cursor
at the end.

this is not a web2py issue, it's how safari and chrome use the
"replace" function. firefox, for example, leaves your cursor where it
was unless it successfully replaces. but it becomes a web2py issue
because inputs of type double have this javascript setting on their
keyup().

the only solution i can think of for now is to have my input fields
select all upon entry, so that the user isn't tempted to use the arrow
keys in the middle. but i wanted to see if anyone else has had to deal
with this.

thanks,

matt

Reply via email to