I'm trying to disable the submit button if I choose one of the dropdown menus that include the text "Trial" in it, but I can't seem to make it work right this time.
Javascript code:
function disableSubmit()
{
//disable submit button
if ($("#inputDropdown").toString().includes("Trial")) {
$("button").attr("disabled","disabled");
} else {
$("button").removeAttr("disabled");
}
}
$(function()
{
$(".inputDropdown").on("change keyup",disableSubmit)
})
Html form:
<form class="mb-3" id="submitform" action="page.php" method="post" accept-charset="UTF-8">
<div class="form-group mb-4">
<label for="name">Name</label>
<input id="name" name="name" class="form-control" type="text" placeholder="Name">
</div>
<div class="form-group mb-4">
<label for="email">Email</label>
<input id="email" name="email" class="form-control" type="text" placeholder="Email">
</div>
<div class="form-group mb-4">
<label for="name">Available Package</label>
<select class="form-control" id="inputDropdown" name="inputDropdown">
<option value="0" selected> - </option>
<option value="1"> Option 1 which is Trial </option>
<option value="2"> Here is another dropdown text </option>
<option value="3"> #3 is the charm but nada </option>
<option value="4"> Whatever you make Trial with it </option>
</select>
</div>
<div class="col-md-2 mx-auto">
<button class="btn btn-primary btn-block" type="submit">Add</button>
</div>
</form>
I'm trying to disable the submit button if someone choses either #1 or #4 which have the word Trial in them.