2017 © Pedro Peláez
 

library form-protector

Protects users from navigating away from forms before submitting them

image

phantomwatson/form-protector

Protects users from navigating away from forms before submitting them

  • Thursday, February 4, 2016
  • by PhantomWatson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 322 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

About

This script protects a form from being navigated away from by throwing up a confirmation dialog if information has been entered but not saved., (*1)

Requirements

  • jQuery

Installation

<script src="form-protector.js"></script>

Example

To protect a form with id MyFormId:, (*2)

<script>
    $(document).ready(function () {
        formProtector.protect('MyFormId');
    });
</script>

This will produce a confirmation dialog if any <input>, <select>, or <textarea> has its value changed and the user navigates away by any means other than submitting the form., (*3)

If you want to manually mark a form as having been changed:, (*4)

<script>
    $(document).ready(function () {
        formProtector.setChanged('MyFormId');
    });
</script>

If you want to manually mark a form as having been saved (e.g. if you have an asynchronous function that stores form data):, (*5)

<script>
    $(document).ready(function () {
        formProtector.setSaved('MyFormId');
    });
</script>

The Versions

04/02 2016

dev-master

9999999-dev https://github.com/PhantomWatson/form-protector

Protects users from navigating away from forms before submitting them

  Sources   Download

MIT

jquery form