javascript - how to return true/false from nested jquery callback functions -


i trying validate elements inside javascript function contains 2 jquery callback loops. based on conditions want return true/false inner jquery loop , should sent calling method of javascript. if result of inner loop true loop should stop running.

if(validate(key)){ } else{ } function validate(key) {     $jquery.each(function(){         $jquery.each(function(){             if(){                 return true;             }             else{                 return false}         })     }) } 

i think you're looking for, stop both loops when true condition met

function validate(key) {     var result = false;     $jquery.each(function(){         $jquery.each(function(){             if(){                 result = true;                 return false;//break inner loop             }         });         if(result)             return false; //break outer loop if got true in inner     });     return result; } 

demo fiddle can open console , see loop stops when true condition met


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -