Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputMask 7.3.2 iOS #734

Open
ramsyFathima94 opened this issue Mar 3, 2025 · 1 comment
Open

InputMask 7.3.2 iOS #734

ramsyFathima94 opened this issue Mar 3, 2025 · 1 comment

Comments

@ramsyFathima94
Copy link

How to set date format to MM/DD/YYYY using InputMask 7.3.2

I'm using the InputMask 7.3.2 library in my iOS project. I want to set the input mask for a date field to display in the format MM/DD/YYYY and also set the placeholder to MM/DD/YYYY.

Here is my code:

import InputMask

class ViewController: UIViewController {
    @IBOutlet weak var dateTextField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Set up the mask for the date field
        let dateMask = "[00]{/}[00]{/}[0000]"
        let listener = MaskedTextInputListener(primaryFormat: dateMask)
        dateTextField.delegate = listener
        
        // Set placeholder text
        dateTextField.placeholder = "MM/DD/YYYY"
    }
}

The input mask works correctly, but the placeholder does not display as expected. It shows MM/DD/YYYY only when there is no input.

Is there a way to keep the placeholder MM/DD/YYYY visible until the user starts typing? Also, how can I ensure the input mask applies correctly as the user types?

Thank you in advance for your help!

@ramsyFathima94
Copy link
Author

It should work as part of the normal workflow. The only difference is that the placeholder will be set to 'MM/DD/YYYY' and it should remain visible until the user has fully typed in the date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant