Table cell to allow only numbers

I want to restrict entries in a table to not allow for a variable and only allow numeric values. I’m able to keep the range students enter between -10 and 10 with some conditional checks but if a student enters in an “x” it doesn’t get flagged.
cellDisableEvaluation doesn’t seem to be solution.
I’ve been stuck on this all day and haven’t been able to think of a solution.
Any help or ideas are greatly appreciated.
Thanks,
Andy

Hey Andy,
I’m not sure which mechanism you are using to restrict values, but here’s a solution that gives a student a warning message if the cell isn’t between -10 and 10 or if the cell is undefined (some text input)

cellErrorMessage(1,1): when t1.cellNumericValue(1,1)<-10 or t1.cellNumericValue(1,1)>10 or isUndefined(t1.cellNumericValue(1,1)) "Enter a value between -10 and 10" otherwise ""

1 Like

I’m looking for a way that will allow for an unknown number of cells so that a student can decide how many points they want to enter into the table. Blank cells being ok as well as a student adding additional rows to the table. I think with your code I’d have to know ahead of time how many cells there would be unless there’s a recursive way of checking all the cells based on the length of the table columns.
My work around right now is to not allow them to submit the challenge if they haven’t solved it themselves–which they won’t be able to if they’ve entered in non numeric values into the table.

1 Like