Jquery does not allow carriage return to trigger form submission
- 2020-03-30 04:35:06
- OfStack
<form class="form-inline definewidth m20" action="/" method="get">
<input type="text" name="title" id="title"class="abc" value="">
<button type="submit" class="btn" style="margin-right:20px"> The query </button>
<select name="school_type" id="school_type">
</form>
<td style="width:90px; height:24px; text-align:center"><input type="text" name="test" value="" class="a"></td>
The return event in the test textbox triggers the submission of the form above. This is the default behavior of the browser. To disable auto-submission, cancel the default event in the textbox.
$('.a').keypress(function(e){
if(e.keyCode==13){
e.preventDefault();
}
IE10 FF29 tested is normal