:: Forum >>

Cell Editing: 2 digits after decimal point

Hi All

I am using AW.Grid 2.5.1. I have a requirement, not allowing user to enter more than 2 digits after decimal point in a grid cell, for example -

If User types 100.00 in a AW.Grid cell, and if he tries to edit cell with new value, let say, 100.999, is not allowed (he can enter 100.99 but not 100.999), but he tries to enter 1002.75, he is allowed to do so.

I am using grid.onKeyPress function. Using event's keyCode, i am able to stop user from entering values other than numbers(0-9, . <decimal point> and - <negative sign>) but, not able to control user to from entering digits after dot. Any suggestions?
Satish Kumar
Monday, June 23, 2008
You can use onCellTextChanging event to restrict the user input. For example, here is the code which only allows to type digits in the cell -

obj.onCellTextChanging = function(text, column, row){

if (column == 1) { // column-1 only
if (text.match(/[^0-9.+-]/)){
return "error"; // prevent non-digits
Alex (ActiveWidgets)
Monday, June 23, 2008

This topic is archived.

Back to support forum

Forum search