Reputation: 559
I have a jquery Datetimepicker and i want to disable the keyboard input. I want only edit this field over the picker (Modalbox).
Upvotes: 4
Views: 22366
Reputation: 41
readonly
attribute on the text input should work for you, use this property in input field either by manually entering or you can set this attribute using Javascript or jQuery.
Set a text field to read-only using Script:
document.getElementById("myText").readOnly = true;
Or in HTML:
<input type="text" name="textName" placeholder="Select date" readonly>
Upvotes: 4
Reputation: 8033
You should disable keyboard on your input like this:
$(function() {
$('#datepicker').keypress(function(event) {
event.preventDefault();
return false;
});
});
Upvotes: 6
Reputation: 4637
Try this prop()
// Disable #x
$( "#x" ).prop( "disabled", true );
// Enable #x
$( "#x" ).prop( "disabled", false );
Upvotes: -1