Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Best way to create a multi-step validation process

$
0
0

I am writing a multi step validation process and I was wondering what is the best method to have it operate on the value.  What I have:

As a custom validation script, in that order:

1- Calls a function that looks if the value is part of a particular array

2- Calls a function that regroup some tests

     2a- function test1()

     2b- function test2()

     2c- function test3()

     2d- function test4()

 

What I have now is every test ends as 'event.rc = false' when they fail which is what I need but I also need to stop the entire validation process.  As an example, if the value fails test2() and gets a "you have failed test 2" alert, I don't want to call test3() and test4() since it is already decided that it failed one of the tests.  I could return a boolean that triggers (or not) the next test() but isn't there a simple way to just say

 

event.rc = false;

"STOP EVERYTHING";

 

I have the assumption that break; will only stop the test() but still move on to the next test().  Maybe I can return break; so it will be called from the 'master function'?   Is that even possible?


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>