Should not allow user to type text in number cell

Hi,

I have a requirement that the user should not be allowed to type the text inside a numeric cell type.

Does handsontable have any in-built feature for that?

If there’s no in-built feature at least guide me how to achive that.

Thanks.

Hi @ebalasubramanian24

You can use beforeKeyDown hook to block a key that doesn’t follow your regex

Demo: http://jsfiddle.net/bfehnyj3/

Got it thanks, but how can I achive that for a particular column or cell?

You can use the getSelectedLast() array to differ which cell is being edited. Here’s an updated demo http://jsfiddle.net/27srvd50/

That’s great!, But when it comes to Angular it’s not working… I tried all the possible ways from my side… do you have any example in angular that I can refer.

Sorry, only vanilla.

Can you share your implementation via Stackblitz? I’ll check what’s wrong.

Ok fine… here is my stackblitz link plz check and let me know.

https://stackblitz.com/edit/angular4-y1qtwe?

Here’s a Angular example https://stackblitz.com/edit/angular-5ykm8c-tukq86?file=src/app/heroes/heroes.component.ts

That’s a great job! Thank you so much! @aleksandra_budnik

1 Like