Skip to main content
cakeytaste
Participating Frequently
March 23, 2017
Question

Play a sound if text field meets criteria

  • March 23, 2017
  • 1 reply
  • 801 views

Hello again.

I'd like to—essentially—have a "green light" or "pass" sound play (I have the .wav already) if a user fills out a text field correctly. Meaning: If "TRUE" is typed into a text field, a .wav will play on blur. I'd love some help working this out.

Note: not all text fields will be true/false, as some will have other one-word answers that I'm seeking. Ideally, I'll have 5 .wav files for 5 possible text field responses.

This topic has been closed for replies.

1 reply

cakeytaste
Participating Frequently
March 29, 2017

I'm wondering if anyone has an idea as to a solution.

try67
Community Expert
Community Expert
March 29, 2017

It can probably be done by using a RichMedia Annotation for the clip and then playing it using a script.

cakeytaste
Participating Frequently
March 29, 2017

I've had no issues playing sound files through the Action menu. I have several .wav files that are "on focus" and what have you, but I'm having issues with the javascript verifying the textfields.

For an even more basic example, when I use the below javascript "on blur", the alert pops up regardless of the value of the field.

var i = this.getField("Initials");

if (i = "AM")

app.alert("AM");

What am I missing that is causing it to trigger on blur without checking the "if" statement?

I've also tried using validation like:

var n = event.value.indexOf("AM");

if (n == -1) { // substring not found

    app.alert("Not AM");

    event.rc = false;

}

else {

    app.alert("AM");

    event.rc = true;

}

And this will correctly pop the "Not AM" alert, but not the true one.