Skip to content

Commit 247ebf7

Browse files
authored
prevent form fields from being submitted on form click/submit (#2263)
1 parent e4d8ced commit 247ebf7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

pygeoapi/templates/collections/items/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h1>{% for l in data['links'] if l.rel == 'collection' %} {{ l['title'] }} {% en
5252
<div class="col-sm-12">
5353
<input class="form-check-input" onchange="checkSpatialFilter()" type="checkbox" id="spatial_filter_check">
5454
<label class="form-check-label" for="spatial_filter_check">Spatial filter</label>
55-
<button type="button" class="btn btn-primary" onclick="submitForm();">Search</button>
55+
<button type="submit" class="btn btn-primary" onclick="submitForm();">Search</button>
5656
<button type="reset" class="btn btn-secondary" onclick="document.getElementById('searchForm').reset();">Reset</button>
5757
</div>
5858
</div>
@@ -192,6 +192,7 @@ <h1>{% for l in data['links'] if l.rel == 'collection' %} {{ l['title'] }} {% en
192192

193193
document.getElementById("q").addEventListener("keydown", function(event) {
194194
if (event.key === "Enter") {
195+
event.preventDefault();
195196
submitForm();
196197
}
197198
});
@@ -288,6 +289,9 @@ <h1>{% for l in data['links'] if l.rel == 'collection' %} {{ l['title'] }} {% en
288289
setRectangle(map.getBounds().pad(-0.95));
289290
}
290291
}
292+
293+
var form = document.getElementById("searchForm");
294+
form.addEventListener("submit", submitForm);
291295
{% endif %}
292296
</script>
293297
{% endif %}

0 commit comments

Comments
 (0)