Disable submit button if entry doesn't exist in tag list

I’ve been at this for a while and can’t find a working JS solution. I have several forms on a page that are similar to this one. They’ll each pull a list from a database as a lookup field. The user can start typing to find matching entries; however, I’d like to disable the option for the form to submit if the typed entry doesn’t exist in the list.

<form  method="post" action="script.php">
  <div class="wtitle">Edit/Lookup</div>
      $(function() {
        var availableTags = [
        $( "#tags3" ).autocomplete({
        source: availableTags
    <input class="wtext" id="tags3" name="site" placeholder="Search by Site Name" required>
    <div class="wbutton">
      <button type="submit" class="btn btn-success fa wbutton">SUBMIT</button>

Here’s a live link:

Any thoughts would be helpful! Thank you!

What about disabling it initially, then only enabling it once the user has selected something from the list. Would that work?

Yes, I just can’t seem to find a way to make that happen. :slight_smile:

Like this?

I hard coded the tags - not sure how that will play with the database functionality.

1 Like

Thank you, I appreciate that, It worked perfectly!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.