Contact Placeholder
TEST CASES
- Restricted the typing of characters other than numbers by implementing a check in the handleKeypressEvent function.
- Applied the maximum length limit on the input field based upon the defined number pattern using the setNumPattern function.
- Implemented automatic formatting of the number while typing according to the specified pattern in the handleInputChange function.
- Set up the placeholder for the input field based on the selected number pattern using the setNumPattern function.
- When a user removes digits from the middle of the formatted number, the caret jumps to the end because the function associated with the oninput event listener is called , which captures the string in the input box containing numbers and special characters. The number is then extracted from the string by removing the special characters. The extracted number is passed to another function that formats the number according to the specified pattern, adding the necessary special characters. The formatted number is then set as the new value of the input field using $('#phone').val(formattedNumber). This triggers the input event again, causing the caret to move to the end of the input field, which is the default behavior of the browser.