i have a page that contains several submit buttons however i only want one of them to be activated by the enter key
echo "<form method=\"post\" action=\"fish.php\">\n";
echo "<tr><td>North Pot</td><td><input type=\"text\" name=\"northpot\"><input type=\"submit\" name=\"north_all\" value=\"All\"></td>\n";
echo "<tr><td>South Pot</td><td><input type=\"text\" name=\"southpot\"><input type=\"submit\" name=\"south_all\" value=\"All\"></td>\n";
echo "<tr><td><input type=\"submit\" name=\"submit4\" value=\"Place\"><input type=\"submit\" name=\"clear\" value=\"Clear\"></td>\n";
echo "<td colspan=\"2\" align=\"center\"></td></tr>\n";
echo "</form>";
The button i want to be actived by the return key is submit4
i can disable the enter key for all the submit buttons but i’m struggling to do this selectively
You can capture and cancel the enter keypress on those fields like this:
Then on your inputs with type as submit just give them a class=”noEnterSubmit” 🙂
In jQuery 1.4.3 you can shorten it to this:
$('.noEnterSubmit').bind('keypress', false);