I have an input set to type “number” that works fine but I also wanted users to be able to pull up a visual/onscreen numpad they could use to enter in a number by clicking the numbers rather than typing it on their keyboard. I want the visual numpad to enter the number into the input so it can be submitted in the same way regardless of it is typed out or enter via the visual one.
So, I made a numbpad on an off-canvas component and added buttons and put an on-click event that adds the clicked number to the input like this
(inp_number.value + “1”) and (inp_number.value + “2”) and so on. I believe the " " is necessary because otherwise it will act as a number and make 1+1=2 rather than 11 but would like some conformation this is the correct way to do it.
My issue is with getting the . to work. When I tried (inp_number.value + “.”) it seems to break the input, it sets it to the placeholder value and won’t let me enter in any numbers.
My other issue is that I’m not sure how I can get a backspace button to work. Essentially, I just want to delete the last character from the input ie 123 -> 12 but I don’t know how to go about doing that.
Has anyone else done anything like this or have any ideas on how to make this work?