How to type numbers in input backwards by putting

how to type numbers in input backwards by putting , or . after two numbers entered. Is there a way to do this AppGyver?

Courtesy of chatGPT-4:
To format numbers in an input field so that they are entered backwards and separated by a comma or period after every two digits, you can use the following regular expression in JavaScript:


This regular expression matches strings that contain up to six pairs of digits separated by commas or periods. The digits are entered in reverse order, so the first pair corresponds to the last two digits of the number, the second pair corresponds to the third and fourth digits, and so on.

To use this regular expression to format the input field in real time, you can attach an event listener to the input field’s “input” event, and use the value property of the input field to check if the current value matches the regular expression. If it does, you can format the value by inserting commas or periods after every two digits in reverse order. For example:

const inputField = document.querySelector('#my-input');

inputField.addEventListener('input', (event) => {
  const value =;

  if (/^\d{0,2}(\d{0,2}([,.])?)?(\d{0,2}([,.])?)?(\d{0,2}([,.])?)?(\d{0,2}([,.])?)?(\d{0,2}([,.])?)?$/.test(value)) {
    const reversedValue = value.split('').reverse().join('');
    const formattedValue = reversedValue.replace(/(\d{2}(?!$))/g, '$1,').split('').reverse().join(''); = formattedValue;
1 Like

Another option is to use the split/reverse functions.

You can learn more about the split function in Appgyver here: Split - text

And the reverse function here: Reverse - list

1 Like

I’m following you on YouTube do you have this tutorial there?


I cover this in part here, though this video covers more also: