views:

64

answers:

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?

+1  A: 

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

Matt Ball
+1  A: 

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.

Commander Keen
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.
GiddyUpHorsey
A: 

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

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