Hi how to disable delete key press or backspace key press when deleting a particular character from a string using jQuery. For example, from string 1234-555 when the cursor is at hypen, if delete key is pressed it should not delete hypen. Instead of that cursor should stay in the same position. Basically disabling the delete key at hyphen. In the same way when the cursor is after hypen, if backspace key is pressed it should not delete hypen. Instead of that cursor should stay in the same position.
Share
Sure, use the
keydownevent.EDIT: to get the current position of the cursor in a text box, you will need to use the following function (provided by @CMS no less):
Now, back to my original answer:
jsFiddle example