mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Validate search
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="description" content="{{ site_conf.about}}">
|
||||
<meta name="author" content="{{ site_conf.site_author }}">
|
||||
<meta name="generator" content="Django Framework">
|
||||
<title>{{ site_conf.site_name }}</title>
|
||||
|
@@ -1,5 +1,24 @@
|
||||
<form class="d-flex" action="{% url 'search' %}" method="post">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="search">
|
||||
<button class="btn btn-outline-primary" type="submit">Search</button>
|
||||
<form class="d-flex needs-validation" action="{% url 'search' %}" method="post" novalidate>
|
||||
<div class="input-group has-validation">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="search" id="searchValidation" required>
|
||||
<button class="btn btn-outline-primary" type="submit">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
'use strict'
|
||||
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
||||
var forms = document.querySelectorAll('.needs-validation')
|
||||
// Loop over them and prevent submission
|
||||
Array.prototype.slice.call(forms)
|
||||
.forEach(function (form) {
|
||||
form.addEventListener('submit', function (event) {
|
||||
if (!form.checkValidity()) {
|
||||
form.classList.add('was-validated')
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}
|
||||
}, false)
|
||||
})
|
||||
})()
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user