An input box calls a function on keyup that automatically inserts a dash or hyphen into the entered text string using regular expressions. The input box allows numbers or text to be entered and the function formats the input with dashes as the user types.
2. Adding A Dash In jQuery:
I am using an input box where Ill enter the numbers or
a text string. The onkeyup event of the input box will
call a function, which will automatically add or insert a
dash (-) or a hyphen to the string, using Regex.