# jquery-warn-before-unload

> Warns before leaving a modified page.

Latest version **1.0.5** (published 2022-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install jquery-warn-before-unload
pnpm add jquery-warn-before-unload
yarn add jquery-warn-before-unload
bun add jquery-warn-before-unload
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-01-25 |
| First published | 2018-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pierre-André Boissinot |
| Maintainers | arnaudlevy, pabois |

## Links

- npm: https://www.npmjs.com/package/jquery-warn-before-unload
- Repository: https://github.com/lespoupeesrusses/jquery-warn-before-unload
- Homepage: https://github.com/lespoupeesrusses/jquery-warn-before-unload#readme
- Issues: https://github.com/lespoupeesrusses/jquery-warn-before-unload/issues
- npm.io page: https://npm.io/package/jquery-warn-before-unload

## Recent versions

- 1.0.5 (latest) — 2022-01-25
- 1.0.4 — 2018-08-01
- 1.0.3 — 2018-08-01
- 1.0.2 — 2018-08-01
- 1.0.1 — 2018-08-01
- 1.0.0 — 2018-08-01

## README

# jQuery Warn Before Unload

Prevents a page from unloading directly when something was changed in any input or text area. Asks whether you are sure or not.

## Getting started

Add with yarn or npm:
```
yarn add jquery-warn-before-unload
```

Then include javascript, for example like that (in a rails project):
```
//= require jquery-warn-before-unload/jquery.warnBeforeUnload
```

## Usage

Any input / select field change triggers an alert if you try to leave the page without saving.
We consider that a form submission clears the alert.

Basically you have some code like that in your html:
```
<form>
  <input type="text" name="myfield">
  <input type="submit">
</form>
```
If you change the text input and try to leave the page (by clicking any link or refresh on your browser) you will trigger the warning. If you just submit the form the warning will not be triggered.

## Exceptions

Please note that inputs/selects with any of those classes: `do-not-warn-before-unload`, `filter` will be ignored and will not trigger the alert.
Input type `search` won't trigger the alert either.
Also note that a form with a class `do-not-unlock` will not remove the alert.

---
_Source: https://npm.io/package/jquery-warn-before-unload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
