How to disable enter key inside jqueryui datepicker
javascript, jquery, jquery-ui
Solution
Try this:
$("#datepicker").keydown(myfunction); // use keydown
function myfunction(e) {
if(e.keyCode === 13) {
e.stopPropagation();
e.preventDefault();
return false;
}
}
Problem
I am using jQueryUI date picker and when user clicks on a textbox and hits the enter key the current date gets populated. I want to avoid that. I have tried this: ``` $('#datepicker').on('keypress', function(e){ if (e.which == 13) { e.preventDefault(); e.stopPropagation(); return false; } }); ``` With no luck here is the link of demo https://jsfiddle.net/shalini456/zwjzo175/