I'm trying to make it easyer for the user to enter a date and a Phone number
Like (XXX)XXX-XXXX oR XX/XX/XXXX
Thanks in Advance ...
posted 9 years ago
You can do one of two things that I know of off the top of my head. One is use a keylistener on the textfield and in your method KeyReleased, validate the last character pressed to see if its consistent with the mask, i.e. if the mask is (XXX) XXX-XXXX, then when they enter the 10th character, make sure its a "-" or enter the dash for them. How you know what character they are on is YourTextField.getText().trim().length() (after checking that getText() is not null).