1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-28 23:59:53 +02:00

Make a form validation handler | handle form messages

add "aria-describedby" attribute on "supported elements" section

add "aria-describedby" attribute on server side succeed validation messages
This commit is contained in:
GeoSot
2021-05-19 18:37:26 +03:00
parent 4cb046a6b8
commit aa6a1ece56
9 changed files with 326 additions and 118 deletions

View File

@@ -4,8 +4,6 @@ title: مثال إتمام الشراء
direction: rtl
extra_css:
- "../checkout/checkout.css"
extra_js:
- src: "../checkout/checkout.js"
body_class: "bg-light"
---
@@ -67,7 +65,7 @@ body_class: "bg-light"
</div>
<div class="col-md-7 col-lg-8">
<h4 class="mb-3">عنوان الفوترة</h4>
<form class="needs-validation" novalidate>
<form data-bs-toggle="form-validation">
<div class="row g-3">
<div class="col-sm-6">
<label for="firstName" class="form-label">الاسم الأول</label>

View File

@@ -1,19 +0,0 @@
// Example starter JavaScript for disabling form submissions if there are invalid fields
(() => {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
const forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()

View File

@@ -3,8 +3,6 @@ layout: examples
title: Checkout example
extra_css:
- "checkout.css"
extra_js:
- src: "checkout.js"
body_class: "bg-light"
---
@@ -66,7 +64,7 @@ body_class: "bg-light"
</div>
<div class="col-md-7 col-lg-8">
<h4 class="mb-3">Billing address</h4>
<form class="needs-validation" novalidate>
<form data-bs-toggle="form-validation">
<div class="row g-3">
<div class="col-sm-6">
<label for="firstName" class="form-label">First name</label>