I am having a textbox which opens jquery datepicker calender when I press enter inside it.
Is there any way to prevent opening the calender on enter press?
Asked
Active
Viewed 263 times
0

user2936213
- 1,021
- 1
- 8
- 19
-
Q&A's here may help http://stackoverflow.com/questions/4753823/jquery-prevent-enter-key (after Googling "jQuery prevent enter") ;-) – Funk Forty Niner Nov 22 '13 at 04:41
-
Thanks for the help but i dont want to completely prevent the enter. I want to call an ajax function on enter press rather than opening the calendar. – user2936213 Nov 22 '13 at 04:44
-
do you have any sample code to start with? by default the calender opens when it gets focus, hitting enter selects the date – Rob Allen Nov 22 '13 at 04:49
-
I have just used `$('.shipdate').datepicker({ inline: true, dateFormat: "yy-mm-dd" });` – user2936213 Nov 22 '13 at 04:52
-
after you get your ajax response what are you doing? – Rob Allen Nov 22 '13 at 04:54
-
do you want to only capture the enter event or when the calender is about to display regardless – Rob Allen Nov 22 '13 at 04:55
-
i am inserting the date in my database. Actually for my ajax to get run i need to press enter twice as on first enter the calendar gets open. And I want my ajax to run on first enter. – user2936213 Nov 22 '13 at 04:56
1 Answers
0
Based on your comments I am convinced there is a better user experience than double tap enter.
Perhaps when a date is selected you could call ajax? There are other options as well that all just utilize the datapicker event callbacks.
$( ".shipdate" ).datepicker(
{
onSelect: function(input, obj) {
//callajax, where input is the date
}
}
);

Rob Allen
- 2,871
- 2
- 30
- 48