Take the 2-minute tour ×

When you want to broke format hh:mm jquery datetimepicker, able to do it. But I want it to block. if you write hh:mm like 1231313:98090909099 it shouldnt be allowed. How can I set time format like 'hh:mm'.

Thanks, Regards

share|improve this question
Which datetimepicker are you using? –  Blazemonger Jul 31 '12 at 21:41
There is no time picker. There are 3rd party modules and plugins, but you can't do time with the jquery date picker, so what are you using? –  Matt Jul 31 '12 at 21:41
trentrichardson.com/examples/timepicker I used first one –  ale Jul 31 '12 at 21:44

2 Answers 2

up vote 1 down vote accepted

I provided set maxlength attribute for datepicker. for example :

$('#datepickerFrom').attr("maxlength", "10");

so it is not allowed for too long charachters.

share|improve this answer

you can create a readonly input and configure datepicker to get only hour and minutes using datetimepicker, an extension of the datepicker plugin:

    timeFormat: 'hh:mm'

<input name="date" id="date" readonly="readonly" />

more info you can find here: http://trentrichardson.com/examples/timepicker/

share|improve this answer
But I have to change date and time manually from input text, it shouldnt be readonly? –  ale Jul 31 '12 at 21:54
aren't you using datepicker? when you click the plugin automatically get values from the calendar/clock and throw into the input! if you want to put time without datepicker, use "meio mask" or "masked input" plugin digitalbush.com/projects/masked-input-plugin –  Rafael Moni Jul 31 '12 at 22:00
yes datepicker,I mean users should be able to write whatever want, not only with slide bar.for example if you want to change date , when even write incorrect type it is converted to correct format. but for time it is not –  ale Jul 31 '12 at 22:05
hmm have you tried any mask? in which case does it convert to correct format, can you give me an example? –  Rafael Moni Jul 31 '12 at 22:11
for example 27/07/12 from here first example (trentrichardson.com/examples/timepicker ) change 2755464/07/12 datepicker is converting 08/01/2012, like that,but ıf you want to change time, it is impossible –  ale Jul 31 '12 at 22:17

Your Answer


