prevent form submit if there is no dropdown item selected
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<style>
|
i<style>
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color: #111;
|
color: #111;
|
||||||
@@ -310,12 +310,19 @@ function customizeSearch(facet) {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- OneSearch widget script from OLS. Used without modification -->
|
<!-- OneSearch widget script from OLS, modified -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function addPrimoQuery() {
|
function addPrimoQuery(e) {
|
||||||
document.getElementById("primoQuery").value = "any,contains," + document.getElementById("primoQueryTemp").value.replace(/[,]/g, " ");
|
// prevent the user from submitting the form if no dropdown item has been selected
|
||||||
/* If you changed the form name at the top, change it below to match */
|
e.preventDefault();
|
||||||
document.forms["searchPrimoForm1"].submit();
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -194,10 +194,7 @@
|
|||||||
<h1 id="onesearch-header">OneSearch</h1>
|
<h1 id="onesearch-header">OneSearch</h1>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="dropdown input-group zero-margin">
|
<div class="dropdown input-group zero-margin">
|
||||||
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">Define Your Search <span class="caret"></span></button>
|
||||||
Define Your Search
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||||
<li>
|
<li>
|
||||||
<div class="yamm-content yamm4">
|
<div class="yamm-content yamm4">
|
||||||
@@ -266,7 +263,7 @@
|
|||||||
<input type="text" class="form-control form-width" name="queryTemp" id="primoQueryTemp" type="search" value="" placeholder="Enter search term here">
|
<input type="text" class="form-control form-width" name="queryTemp" id="primoQueryTemp" type="search" value="" placeholder="Enter search term here">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group zero-margin">
|
<div class="input-group zero-margin">
|
||||||
<input type="submit" class="btn btn-default form-control" value="Search" type="submit" onclick="addPrimoQuery();" />
|
<input type="submit" class="btn btn-default form-control" value="Search" type="submit" onclick="return addPrimoQuery(event);" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user