Sets boolean data attribute if field is empty.
Being a void element, an <input>
element is considered empty by the HTML definition of "empty", since the content model of all void elements is always empty. So they will always match the :empty
pseudo-class, whether or not they have a value. This is also why their value is represented by an attribute in the start tag, rather than text content within start and end tags.
$ npm install input-is-empty
import InputIsEmpty from 'input-is-empty';
const htmlInputElement = document.querySelector('input-selector');
new InputIsEmpty(htmlInputElement, {/* options */});
Note: Default is
change
Event
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form accept-charset="utf-8">
<input type="" name="">
</form>
<script type="module">
import InputIsEmpty from 'input-is-empty';
const htmlInputElement = document.querySelector('input');
new InputIsEmpty(htmlInputElement);
</script>
</body>
</html>
Type: String
Default: change
Description: Event at which the boolean date attribute value will change