CodeIgniter Forums
Shopping cart library and input field formating - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Shopping cart library and input field formating (/showthread.php?tid=51624)



Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]tmengttm[/eluser]
Hi all,

Update:

Previously, i was asking: is there a way to extend/modify ci shopping cart library to make "qty" accept double value. Because it seemed to me that "qty" only accepts integer value. thanks jmadsen, the problem is solved. It turns out that I just need to change the code in system/library/cart file...

Now my questions is:

Is there a way to format input field in such a way: a number with 1 decimal place?


Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]jmadsen[/eluser]
At first glance, lines 161 & 332 use a preg_replace to strip non-numerics, including decimals.

If you extend & change those to:

Code:
$items['qty'] = trim(preg_replace('/([^0-9\.])/i', '', $items['qty']));

I think it should work for you.


Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]tmengttm[/eluser]
Hi Jmadsen, Thanks, I just found that.
I edited my question a bit. now i want to know is there a way to format input field. i.e when user do input, they'll see the format is sth like: __._ , and whatever they input first will be pushed to decimal place first, then fill other digits..
Thanks


Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]jmadsen[/eluser]
uhm...did you just edit & completely change your question? this was about extending the shopping cart a moment ago


Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]jmadsen[/eluser]
Uhm.... don't do that again, ok? When you post a question, leave it there for others.


Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]InsiteFX[/eluser]
jQuery Validatation Plugin

How to Mask Input with jQuery




Shopping cart library and input field formating - El Forum - 05-11-2012

[eluser]weboap[/eluser]
http://digitalbush.com/projects/masked-input-plugin/