How to check the last character entered using a regular expression? For example, if the previous character in the string is the digit 3, then the next character can be a number from 0 to 6, otherwise from 0 to 9.

    1 answer 1

    You can check the last two characters in the string that you enter to the fact that there are really numbers and they satisfy the condition:

    /(3[0-6]|[0-24-9]\d)$/