-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvalidation.html
More file actions
68 lines (55 loc) · 3.52 KB
/
Copy pathvalidation.html
File metadata and controls
68 lines (55 loc) · 3.52 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script type="module" src="../src/index.ts"></script>
<script type="module" src="./mocks/scoped-element-test.ts"></script>
<link href="../src/themes/day.css" rel="stylesheet" type="text/css" />
<link href="../src/themes/night.css" rel="stylesheet" type="text/css" />
<link href="../src/css/sgds.css" rel="stylesheet" type="text/css" />
<form id="validation-form_constraint-validation" class="d-flex-column">
<request-form></request-form>
<sgds-checkbox-group required hasFeedback id="sameid">
<sgds-checkbox value="he">he</sgds-checkbox>
<sgds-checkbox value="him" >him</sgds-checkbox>
</sgds-checkbox-group>
<!-- <sgds-input id="sameid" label="First Name" hinttext="type Sarah" name="firstName" hasfeedback="both" placeholder="Placeholder" pattern="yes" >
</sgds-input>
<sgds-datepicker required="" hasfeedback="" name="appointmentDate" label="Appointment date"></sgds-datepicker>
<sgds-combo-box multiSelect required="" hasfeedback="" name="countryOfBirth" label="Country of birth" menulist="[
{ "label": "Singapore", "value": "1" },
{ "label": "Thailand", "value": "2" },
{ "label": "Malaysia", "value": "3" },
{ "label": "Philippines", "value": "4" },
{ "label": "Japan", "value": "5" },
{ "label": "Laos", "value": "6" },
{ "label": "Vietnam", "value": "7" },
{ "label": "China", "value": "8" }
]" placeholder="Choose a country"></sgds-combo-box>
<sgds-quantity-toggle label="Number of dependents" name="dependentCount" min="1" max="10" hinttext="Input number 1 to 10 only" hasfeedback="both"></sgds-quantity-toggle>
<sgds-checkbox-group hasfeedback="" hinttext="hint for checkbox" label="Agreements">
<sgds-checkbox name="consentA" value="consentA">I consent to ...</sgds-checkbox>
</sgds-checkbox-group>
<sgds-radio-group hasfeedback="" name="gender" required="" label="Gender">
<sgds-radio value="female">Female</sgds-radio>
<sgds-radio value="male">Male</sgds-radio>
</sgds-radio-group>
<sgds-textarea name="comments" minlength="3" required="" hasfeedback="" resize="auto" label="Comments" hinttext="Required to fill with minimum length of 3"></sgds-textarea>
<sgds-file-upload required="" label="Supporting documents" multiple="" name="documents" hasfeedback="">File upload</sgds-file-upload> -->
<div class="d-flex-row">
<sgds-button type="submit" id="submit">Submit</sgds-button>
<sgds-button type="click" id="trial">Trial</sgds-button>
<sgds-button type="reset" id="reset" variant="ghost">Reset</sgds-button>
</div>
</form>
<script>
const trial = document.querySelector("#trial")
trial.addEventListener("click", () => {
const checkboxgroup = document.querySelector("sgds-checkbox-group")
checkboxgroup.value = "he;him"
})
const form = document.querySelector('#validation-form_constraint-validation');
form.addEventListener('submit', event => {
event.preventDefault();
const formData = new FormData(form);
// formdata gets modified by the formdata event
console.log(formData.get('gender'));
alert('All fields are valid!');
});
</script>