Magento js validation for decimal numbers – only

Magento js validation for decimal numbers – only

The Magento prototype function validate-numbers in js/prototype/validation.js is not working fine.

That function gives you the possibility to add whitespaces and other “blank” characters in the input field. That behavior could raise PHP fatal errors in the admin when you try to list a field marked as number by Magento but not correctly parsed by javascript, due to the Magento object inheritance. That results in blocking totally the access to that page of backend (in our customers’ case: the orders listing!)

That’s our solution to fix that: adding a validation method to the js object that accepts numbers and “.” only (add a js file in your layout to don not modify the core):