2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-08 17:22:31 +03:00

Make a form validation handler | handle form messages

This commit is contained in:
GeoSot
2021-05-19 18:37:26 +03:00
parent b6d27899fc
commit d18697cb5e
9 changed files with 311 additions and 103 deletions
@@ -4,8 +4,6 @@ title: مثال إتمام الشراء
direction: rtl
extra_css:
- "../checkout/form-validation.css"
extra_js:
- src: "../checkout/form-validation.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>
@@ -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)
})
})()
@@ -3,8 +3,6 @@ layout: examples
title: Checkout example
extra_css:
- "form-validation.css"
extra_js:
- src: "form-validation.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>