Reputation: 4981
I'm using Jquery DateTimePicker and I added to the javascript library an input element to change the time because by default we can change the time with a slider or select box only.
My inputs work well (I have one input for the hours and another for the minutes) but I want to add an event to my inputs onChange or onKeyPress to set some restrictions as "if the value is >59 then the value == 59"
create: function(tp_inst, obj, unit, val, min, max, step){
$('<input class="ui-timepicker-input" value="'+val+'" style="width:50%">')
.appendTo(obj)
.spinner({
min: min,
max: max,
step: step,
change: function(e,ui){ // key events
// don't call if api was used and not key press
if(e.originalEvent !== undefined)
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
},
spin: function(e,ui){ // spin events
tp_inst.control.value(tp_inst, obj, unit, ui.value);
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
}
});
return obj;
},
options: function(tp_inst, obj, unit, opts, val){
if(typeof(opts) == 'string' && val !== undefined)
return obj.find('.ui-timepicker-input').spinner(opts, val);
return obj.find('.ui-timepicker-input').spinner(opts);
},
value: function(tp_inst, obj, unit, val){
if(val !== undefined)
return obj.find('.ui-timepicker-input').spinner('value', val);
return obj.find('.ui-timepicker-input').spinner('value');
}
I don't know where I can add my event on the inputs text.
Upvotes: 0
Views: 276
Reputation: 4981
Ok I solved my problem with this :
$(document).on('keypress', '.ui-timepicker-input', function(ev){
alert("ok");
});
I Hope this will help.
Upvotes: 1