Skip to content

Instantly share code, notes, and snippets.

@timbuethe
Created January 20, 2014 13:18
Show Gist options
  • Save timbuethe/8519701 to your computer and use it in GitHub Desktop.
Save timbuethe/8519701 to your computer and use it in GitHub Desktop.
A Pen by Tim Büthe.
<form onsubmit="alert('form submitted'); return false;">
<input type="submit" id="reset" value="Reset" onclick="console.log('reset clicked')"/>
<input type="submit" id="save" value="Save" onclick="console.log('save clicked')"/><br />
<input type="text"/><br />
<input type="password"/><br />
<select name='options'>
<option value='option-1'>Option 1</option>
<option value='option-2'>Option 2</option>
<option value='option-3'>Option 3</option>
</select> <br />
<textarea cols="30" rows="10"></textarea>
</form>
$(function(){
$('form').on('keypress', function(event){
if(event.which === 13 && $(event.target).is(':input')){
event.preventDefault();
$('#save').trigger('click');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment