If text area contains character then trigger alert

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

If text area contains character then trigger alert

amdl
Hello, I hope everyone is well.

I am creating an application where users can type a message into a text area. I want it so that when they type the character "@" then an alert is triggered. My textarea is #usermsg. At the moment I have the following but I think I could be barking up the total wrong tree with it. Any help would be appreciate. Thanks


if ($('#usermsg[value~="/@/"]'))

alert('test message');

}