enter-means-submit

1.0.2 • Public • Published

enter-means-submit

NPM

For all inputs in the given div, enter means submit!

It'll trigger a submit for the first submit button it finds in that div.

Usage

npm install enter-means-submit

In your browser (with browserify)

var enterMeansSubmit = require('enter-means-submit')
 
var forms = document.getElementsByClass('enter-means-submit')
enterMeansSubmit(forms)
<div class="form enter-means-submit">
  <input type="text" name="mytext" placeholder="enter your text..." />
  <button name="cancel-btn">Cancel</button>
  <button type="submit" name="submit-btn" onclick="submit()">Submit</button>
</div>

Typing "enter" in the input element triggers a click event for the button with type="submit". In this example, submit() would be called.

You can also call enter-means-submit with one element.

Package Sidebar

Install

npm i enter-means-submit

Weekly Downloads

2

Version

1.0.2

License

BSD

Last publish

Collaborators

  • karissa