prevent form submit if there is no dropdown item selected

This commit is contained in:
Mark Eaton
2021-02-27 21:10:19 -05:00
parent a9aac6ac10
commit a6cf8038bc
2 changed files with 15 additions and 11 deletions
+13 -6
View File
@@ -1,4 +1,4 @@
<style>
i<style>
body {
color: #111;
@@ -310,12 +310,19 @@ function customizeSearch(facet) {
};
</script>
<!-- OneSearch widget script from OLS. Used without modification -->
<!-- OneSearch widget script from OLS, modified -->
<script type="text/javascript">
function addPrimoQuery() {
document.getElementById("primoQuery").value = "any,contains," + document.getElementById("primoQueryTemp").value.replace(/[,]/g, " ");
/* If you changed the form name at the top, change it below to match */
document.forms["searchPrimoForm1"].submit();
function addPrimoQuery(e) {
// prevent the user from submitting the form if no dropdown item has been selected
e.preventDefault();
e.stopPropagation();
if (document.getElementById("dropdownMenu1").innerHTML === 'Define Your Search <span class="caret"></span>') {
$("#dropdownMenu1").trigger('click.bs.dropdown.data-api');
return true;
};
document.getElementById("primoQuery").value = "any,contains," + document.getElementById("primoQueryTemp").value.replace(/[,]/g, " ");
/* If you changed the form name at the top, change it below to match */
document.forms["searchPrimoForm1"].submit();
}
</script>