About

feedback.js it's simple library with beautiful API for validation and sending forms.

Why use feedback.js?
  1. You don't need thinking about browser supporting, supports ie9+
  2. You can sending data with files, if browser not supports FormData feedback.js sends form to iframe
  3. Very simple API
  4. Convenient validation
  5. Your code becomes more understandable and takes up less space
  6. Without dependencies

Installation

Include feedback.min.js use cdn (click for copy to clipboard)

copied to clipboard
<script src="https://cdn.jsdelivr.net/gh/furashcka/feedback.js@0.1.10/dist/feedback.min.js"></script>

Install via NPM


npm i @furashcka/feedback.js
            

Install via Yarn


yarn add @furashcka/feedback.js
            

Quick start

Options and Events

default options

var el = document.querySelector("form");
var opts = {
  focusIncorrectInput: true,
  fireSchemaByTurn: true,
  blockSubmitWhenFormSending: true,
  fireValidateAndAjaxWhenSubmit: true,
  resetFormAfterAjax: true,
  schema: {},
  validationStep: 0,
  validationStepChanged: function() {},
  ajax: {
    loadingClass: "--loading",
    url: el.action || location.href,
    method: el.method || "POST",
    iframePolyfill: "auto",
    iframePostMessage: false,
    iframeTimeout: 0,
    before: function() {},
    after: function() {},
    success: function() {},
    error: function() {},
    progress: function() {}
  },
  validate: {
    before: function() {},
    after: function() {},
    success: function() {},
    error: function() {}
  }
}

var feedback = new Feedback(el, opts);
            

API


// you can do:
feedback
  .schema( /* ... */ )
  .validate( /* ... */ )
  .ajax( /* ... */ )
  /* ... other API */;

// or

feedback.schema( /* ... */ );
feedback.validate( /* ... */ );
feedback.ajax( /* ... */ );
            

Examples