bootstrap table: JQuery in each method to bind blur event listener input input legality, into an infinite loop

I. Description of the problem: bootstrap table has a row for each input block, for each input to check whether the numerical value of between 1 and 10 (decimal retain a), each time before the event no unbundling bind event , resulting in the number of clicks alert event incrementing the last cycle of death

Second, the solution: each time before unbundling binding events

// determined input value between 1 and 10, may be a decimal places 
            $ ( "INPUT [name = 'SelfScoreA']"). Each (function () { 
                var binded = $ (the this) .attr ( "blurbinded" ); // if there labeled binding 
                if (binded) {return;} // return there directly bound 
                $ (this) .unbind ( "blur "); // unbundling 
                $ (this) .bind ( 'blur ' , function () { 
                    $ (the this) .attr ( "blurbinded", "binded"); // each trigger event to mark 
                    if {($ .trim ($ ( this) .val ()) = ""!) 
                        IF (isNaN ($ (the this) .val ())) { 
                            Alert ( "Please enter 1 ~ 10! '); 
                        }  
                        the else IF (/ ^ ((0 \ [1-9] {1}) | (. ([1-9] {1}) (\ \ d {1}.)) |? 10) $ / test ($ (this)..val ()) == false) {
                            Alert (" Please enter 1 ~ 10!'); 
                        } 
                        the else IF ($ (the this) .val ()> 10 || $ (the this) .val () < = 0 ) { 
                            alert ( 'Please fill in 1 to 10 minutes ! '); 
                        } the else { 
                            row.score = $ (the this) .val ();
                         } 
                    } 
                }); 
            });

 

Guess you like

Origin www.cnblogs.com/CherishZeng/p/10963404.html