-
-
Notifications
You must be signed in to change notification settings - Fork 927
/
Copy pathminlength-input.html
49 lines (46 loc) · 1.54 KB
/
minlength-input.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
This is minlength validity test (#2256).
Open your browser's Developer Console and follow these steps:
<ol>
<li>Type any (1 or 2) characters in the input field.</li>
<li>Click “submit.”</li>
<li>Click “submit” again.</li>
<li>Check the logs displayed in the console.</li>
</ol>
<div id="root"></div>
<script src="../../../mithril.js"></script>
<script>
let input, value;
m.mount(document.getElementById("root"), {
view: () => [
input = m("input[type=text]", {
value,
minLength: 4,
required: true,
oninput(e) {
value = e.target.value;
check();
}
}),
m("button", {
onclick(e) {
console.log("click");
check();
}
}, "submit")
],
});
function check() {
console.log(`tooShort: ${input.dom.validity.tooShort}`,
`valueMissing: ${input.dom.validity.valueMissing}`,
`checkValidity: ${input.dom.checkValidity()}`
);
}
</script>
</body>
</html>