javascript — создание функции клавиши ввода, например клавиши табуляции

Друзья, я знаю, что уже есть много решений этого вопроса, и я использовал его, но по неизвестной причине он не работает в моем приложении. Поэтому, пожалуйста, помогите мне и дайте мне знать, где я иду не так. Пожалуйста, не отмечайте этот вопрос как дубликат. Мне серьезно нужна ваша помощь.
Заранее спасибо.
вот что я пробовал

// Catch the keydown for the entire document
$(document).keydown(function(e) {

// Set self as the current item in focus
var self = $(':focus'),
// Set the form by the current item in focus
form = self.parents('form:eq(0)'),
focusable;

// Array of Indexable/Tab-able items
focusable = form.find('input,a,select,button,textarea,div[contenteditable=true]').filter(':visible');

function enterKey(){
if (e.which === 13 && !self.is('textarea,div[contenteditable=true]')) { // [Enter] key

// If not a regular hyperlink/button/textarea
if ($.inArray(self, focusable) && (!self.is('a,button'))){
// Then prevent the default [Enter] key behaviour from submitting the form
e.preventDefault();
} // Otherwise follow the link/button as by design, or put new line in textarea

// Focus on the next item (either previous or next depending on shift)
focusable.eq(focusable.index(self) + (e.shiftKey ? -1 : 1)).focus();

return false;
}
}
// We need to capture the [Shift] key and check the [Enter] key either way.
if (e.shiftKey) { enterKey() } else { enterKey() }
});

HTML-код

<form id="purchase" action="p_senddata.php" method="POST" >
Bill_no:<input type="text" name="p_billno" id="pbillno"    /><br />
Date:<input type="text" name="p_date" id="pdate"  /><br />
Name of party:<input type="text" name="p_nameofparty" id="pnameofparty" /><br /><br />

<input type="submit">
</form>

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector