3

I have an input text element being used as a jQuery UI datepicker with a custom date format. The date format allows months to be entered in as JAN, FEB, etc and so the constrained input allows all characters to go through. See this question.

How can I restrict the text entered to match my date format "dd-M-yy"?

Is there a way to use jQuery to make the input text element behave like a masked edit text box?

2
  • Is it dd-M-yy or dd-MM-yy? Commented Jul 15, 2010 at 4:44
  • dd-M-yy e.g. 15-JUL-2010 Commented Jul 15, 2010 at 5:26

3 Answers 3

1

I'd recommend using the jQuery MaskedInput plugin, assuming your input is fixed-width.

Sign up to request clarification or add additional context in comments.

Comments

1

It's a bit dirty, but maybe you can use http://www.zurb.com/playground/jquery-text-change-custom-event to create your own filter?

The plugin isn't dirty mind you, it looks great, but it might be the wrong hammer for this nail.

1 Comment

While Bears will eat you's answer had the closer matching tool, this answer was also very useful and I'm actually using both to implement the masking and validation that I need.
0

if you are using a jquery date picker you have built in support for this allready inside the plugin

you can specify the "constrainInput" option inside the datepicker its a boolean just set it to true. and avcorse sepcify your date format.

http://docs.jquery.com/UI/Datepicker#option-constrainInput

1 Comment

That doesn't work for my scenario. See the link in my question above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.