Flickr4Java icon indicating copy to clipboard operation
Flickr4Java copied to clipboard

InputMask 7.3.2 iOS

Open ramsyFathima94 opened this issue 8 months ago • 1 comments

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 avatar Mar 03 '25 10:03 ramsyFathima94