Improved the `textField shouldChangeCharactersInRange` method.