Disable Button If Input Is Empty jQuery snbutton - Download Disable Submit Button If Input Is Empty - jQuery snbutton

Download Disable Submit Button If Input Is Empty – jQuery snbutton

Posted on

This time I will share jQuery Plugin and tutorial about Disable Submit Button If Input Is Empty – jQuery snbutton, hope it will help you in programming stack.

Disable Button If Input Is Empty jQuery snbutton - Download Disable Submit Button If Input Is Empty - jQuery snbutton

File Size: 4.99 KB
Views Total: 5430
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

snbutton is a super small, cross-browser jQuery plugin that disables the submit button (and changes its content) whenever an input field is empty.

How to use it:

1. Load the snbutton plugin’s script snbutton.js after jQuery JavaScript library as this:

1 <script src="//code.jquery.com/jquery.min.js"></script>
2 <script src="snbutton.js"></script>

2. Initialize the plugin and we’re ready to go.

1 SNButton.init("snbtn");

3. Add the ID ‘snbtn’ to the submit button and specify the related input field using data-snnode attribute:

1 <input id="some-input-field" placeholder="input something">
2 <button id="snbtn" data-snnode="some-input-field">SUBMIT</button>

4. Change the text when the submit is disabled or enabled.

1 <input id="some-input-field2" placeholder="input something" />
2 <button id="snbtn2" data-snnode="some-input-field2">SUBMIT</button>
1 SNButton.init("snbtn2", {
2   enabletext:"OK Submit",
3   disabletext:"Input First"
4 });

5. Apply the plugin to multiple input fields.

1 SNButton.init("snbtn", {
2   fields: ["some1", "some2", "some3"]
3 });

Change log:

2017-08-27

  • allows to apply the plugin to multiple fields.

This awesome jQuery plugin is developed by jvyyuie. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net