Skip to content

Disable/Enable the browser default behaviour of submitting a form when the enter key is pressed on any of it's children input or select elements.

Notifications You must be signed in to change notification settings

CottaCush/keyboard-submit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keyboard Submit

Disables or enables the browser's default behaviour of submitting a form when the enter key is pressed on any of it's children input elements.

Please note that this plugin requires jQuery.

Usage

The plugin can be used in the following ways:

  1. through the presence of a form's data- attribute.
  2. through the jQuery interface $.keyboardSubmit()

Using Data attributes

You can disable form submit by simply adding the data attribute in the following way:

<form data-keyboard-submit>
   ...
</form>

You can also pass any valid action into the data attribute as shown below

<form data-keyboard-submit="disable">
   ...
</form>

Using the jQuery interface

You can also activate the plugin it's defined jQuery method

$(form).keyboardSubmit()

Like using data attributes, you can also pass a valid action into the method.

$(form).keyboardSubmit(true)

Valid Actions

The following are valid actions that can be used with the plugin

Actions Type Description
true, 'true', 'enable' Boolean or String Forms can be submitted using the enter/return key. This is the browser's default.
false, 'false', 'disable', '' Boolean or String Disable submitting forms using the keyboard. The empty string ('') here handles scenarios of forms with data attributes without a value

About

Disable/Enable the browser default behaviour of submitting a form when the enter key is pressed on any of it's children input or select elements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published