Reputation: 125
I have a lot of forms that are submitted either by clicking an explicit <input type="image">
or the enter key.
The code used is:
<input width="62" type="image" height="22" border="0" onclick="flipSearchButton()" alt="Search" tabindex="9" src="/images/button-search.gif">
These forms have now been redeveloped and the code looks like this
<a onclick="javascript:flipSearchButton();" class="button blue right" tabindex="9" href="javascript: submitform("main")">Search</a>
However, since the change, while clicking the enter key does not submit the form.
How can I make the enter button to submit the form?
The html section of the input and clear buttons of the form is:
<div class="inline">
<a class="icon blue left" onClick="javascript:resetForm();">Clear</a>
</div>
<div id="search_clickable">
<a tabindex="14" class="button blue right" href="javascript:flipSearchButton();submitform('main')">Search</a>
</div>
<div id="search_unclickable" class="disp_none;">
<a class="button blue right" href="">Searching...</a>
</div>
<script type="text/javascript">
function resetForm() {
var formObj = document.main;
formObj.subCategory.value = '';
formObj.surname.value = '';
formObj.includeSurnameVariants.checked = false;
formObj.forenames.value = '';
formObj.forenames.focus();
formObj.includeForenamesVariants.checked = true;
formObj.eventYear.value = '';
formObj.eventYearTolerance[3].selected = true;
formObj.county.value = '';
}
$(document).ready(function() {
document.main.forenames.focus();
});
</script>
Upvotes: 0
Views: 597
Reputation: 38147
$('.submitme').keypress(function(e){
if(e.which == 13){
submitform('main');
}
});
Add this code then add the class submitme
to the input field you want the form to submit on when the enter key is pressed - this will call the submitform()
method
Upvotes: 1
Reputation: 92893
Try this:
<a class="button blue right" tabindex="9"
href="javascript:flipSearchButton();submitform('main')">Search</a>
Upvotes: 1