To implement the function in Javascript, when the text box loses focus, you can determine the length of the input string to verify whether the input string is out of the range. If the input string is out of the range, it is automatically intercepted. At first, the onkeyup event of js was used, but it was never triggered. This event does not know where to monitor it. js events can be transferred or blocked. This is very troublesome and there are too many situations. After searching for a long time, I finally found a solution that can be solved through the onpropertychange event.
The Code is as follows:
$ ("# TextboxID"). bind ("onpropertychange", function (){
// Alert ($ (this). text ());
// The logic code that is automatically intercepted
});
Firefox does not have onpropertychange
The following code is recommended for better compatibility.
The Code is as follows:
JQuery ("# txtContent"). keypress (function (){
}). Keyup (function (){
});