From a user experience perspective there are some issues about your implementation here.
First, as an end user I would not like to see a warning as soon as I start to write on a text box. You better show this alert/warning when the user is done with the user textbox. You should consider lost focus event for this.
Second it's not a good idea to play a sound when an input has reached it's maximum. The device that your user is using may not have sound functionality or a disabled sound device. Even the user could be hearing imparient. MaxLenght should be enough for most cases. If you want more emphasis on this restriction you can place a warning next to input, with somehow low visibility.
I know this is not an answer to your question but can help you in some way.