-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy path05-radio-inputs.html
51 lines (45 loc) · 1.47 KB
/
05-radio-inputs.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
50
51
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>Custom check functions</title>
<link href='styles.css' rel='stylesheet'>
<script src='../nod.js'></script>
</head>
<body>
<form action=''>
<div>
<input class='radio' type='radio' name='a' value='1'>
</div>
<div>
<input class='radio' type='radio' name='a' value='2'>
</div>
<div>
<input class='radio' type='radio' name='a' value='3'>
</div>
<div class='error-message-here'></div>
<button class='submit-btn'>Submit</button>
</form>
<script>
var myNod = nod();
myNod.configure({
form: 'form',
preventSubmit: true,
submit: '.submit-btn'
});
myNod.add({
selector: '.radio',
// We check that "some radio button has been ticked".
validate: 'some-radio',
errorMessage: 'custom error span?'
});
// Without this, each input element will get an error message
// behind it. With this, we just display one error message, at the
// bottom.
myNod.setMessageOptions({
selector: '.radio',
errorSpan: '.error-message-here'
});
</script>
</body>
</html>