xxxxxxxxxx
1
<form class="needs-validation" novalidate method="post">
2
3
4
<div class="form-outline mb-4">
5
<input type="text" name="fullname" required class="form-control" id="fullname" aria-label="Full Name">
6
<label for="fullname" class="form-label ">Ονομα/Επωνυμία</label>
7
<div class="invalid-feedback">Υποχρεωτική τιμή.</div>
8
</div>
9
10
11
<div class="form-outline mb-4">
12
<input type="tel" name="contactphone" class="form-control" id="contactphone" aria-label="contactphone">
13
<label for="contactphone" class="form-label">Τηλ.επικοινωνίας</label>
14
</div>
15
16
<div class=" form-outline mb-4">
17
<textarea class="form-control" name="message" required id="message" rows="4"></textarea>
18
<label for="message" class="form-label ">Μήνυμα</label>
19
<div class="invalid-feedback">Υποχρεωτική τιμή.</div>
20
</div>
21
22
<div class="d-grid">
23
<button type="submit" class="btn btn-primary">Send message</button>
24
</div>
25
26
27
</form>
1
1
xxxxxxxxxx
1
// Example starter JavaScript for disabling form submissions if there are invalid fields
2
(() => {
3
'use strict';
4
5
// Fetch all the forms we want to apply custom Bootstrap validation styles to
6
const forms = document.querySelectorAll('.needs-validation');
7
8
// Loop over them and prevent submission
9
Array.prototype.slice.call(forms).forEach((form) => {
10
form.addEventListener('submit', (event) => {
11
if (!form.checkValidity()) {
12
event.preventDefault();
13
event.stopPropagation();
14
}
15
form.classList.add('was-validated');
16
}, false);
17
});
18
})();
Console errors: 0