Streaming live at 10am (PST)

Show div when text entered into field - Custom code

Good morning!

I am trying to use custom code to make a div container visible when text has been entered into a form field. (The reason I am not using an interaction trigger is because tabbing through the form does not cause the div to appear as it only appears on a click event).

Here is my custom code so far:
The form id is #contactmessage
The div I want to appear is set to hidden and its id is #vcontainer

<script>
$(function () {
    var rec = "a";
    $("#contactmessage").keyup(function () {
        var text = $(this).val();
     			if (text === rec) {
            $(".vcontainer").show();
        } else {
            $(".vcontainer").hide();
        }
    });
  });
</script>

I have been using the input “a” as a test case, but would like any entry to trigger the event.**

Unfortunately, It is not working for me. I’d love help!
Thank you!!