all,
I’m making a shopping cart that only accept input number with 1 decimal place.
The following is piece of code I get from a library (with some modification):
$items['qty'] = trim(preg_replace('/([^0-9\.])/i', '', $items['qty']));
This will accept any number. but I want to make it as only 1 decimal. how to modify the code?
Thanks
You can remove the decimal places after the first decimal place:
See it