Validating form for gaps in ranges - Fishing for ideas on how to make it work.

I'm probably going to go overboard on information.  I figure it's better to know to much than not to know enough.

I have a single page application built with PHP, AngularJS, and Twitter Bootstrap.  The SPA manages rules.  Each rule has conditions.  Each condition has a buyer, and a dollar range.  A rule may have a single condition, or a rule may have multiple conditions (there may be up to nine legal ASCENDING ranges e.g. $0 - $2,000, $2,001 - $2,500, etc.).  Whether there is a single condition, or there are multiple conditions in a rule, all dollar ranges must be accounted for from $0 to $999,999,999.

Currently, I validate whether or not all ranges are accounted for by subtraction.  I start with a variable equal to 999,999,999 and subtract the difference of each condition range in a loop (e.g. 25,001 - 50,000 would subtract 24,999 from 999,999,999) from that variable.  If when the loop finishes, the variable is not equal to 0, then the ranges have not been properly accounted for and a warning message is displayed.

The requirement that is coming down the pipes is that I somehow force the user to address the gaps, overlaps, or illegal ranges.  I have a couple of ideas on how to make this happen, but I wanted to get some fresh input and see what others might do to force the user to address the improper ranges.

So far, my thoughts are along these lines:
- Wait to save any changes until the user is done making any and all changes.  That is, once a change is made, a submit button magically appears to save their changes.  Said submit button would be in an inactive/disabled state until all dollar ranges are accounted for.  If all ranges are accounted for, only then would the submit button be active/enabled so that they could actually save their changes.
- Once a change is made to a condition, a condition is added, etc., then the main form elements (Search By, and Lookup) are disabled until they save their changes, there by forcing them to either save or cancel their changes.  They could simply leave the page, but since their changes aren't committed until the step above is completed, it would be a no harm no foul situation.

What do you think?  What would you do?

In the SPA's current state, the following is true:

A) When a condition is added to a rule, there is a form which allows the user to select both a buyer, and a dollar range to said condition.  Conditions can be added to rules without conditions.  Conditions may also be added to rules with existing conditions.  

B) The range of an existing condition may be altered by a user.

C) If the cumulative ranges of a rules conditions do not range completely from $0 to $999,999,999, a warning is shown to the user indicating that a gap, an overlap, or an illegal range is in play.

D) Conditions can be removed by the user, which creates a gap if the other conditions are not altered in the case of a rule with multiple conditions.  If a condition is removed from a rule where said condition is the only condition, it is valid, since a rule may have no conditions associate to it legally.  However, if any conditions are present, then all dollar ranges MUST be accounted for.

E) Once any of the aforementioned forms are submitted, the database is updated on the fly (Ajax) and AngularJS pushes the data under the Change Requests in Process header below the rule conditions (oddly enough, the conditions for a rule are called conditions...  I work for the government, so that explains that).

Dollar Range Requirements:
General - Dollar Range(s) must cumulatively range from $0 to $999,999,999
No Gaps - All dollar ranges must be accounted for.
              Rule Condition A: $0 - $25,000
              Gap (Unaccounted Dollar Range): $25,001 - $50,000
              Rule Condition B: $50,001 - $999,999,999
No Overlap - Dollar ranges may not be accounted for more than once in a single rule with multiple conditions.
              Rule Condition A: $0 - $50,000
              Rule Condition B: $25,001 - $999,999,999
              Overlap (Multiple Assignments of a Single Dollar Range): $25,001 - $50,000
No Illegal Ranges - Anything that defies COMMON SENSE
              Illegal Condition: $50,000 - $25,000

Dollar Range Form Select Box Values
Minimum Dollar Ranges: 0 | 2,001 | 2,501 | 10,001 | 25,001 | 50,001 | 100,001 | 1,000,001 | 5,000,001
Maximum Dollar Ranges: 2,000 | 2,500 | 10,000 | 25,000 | 50,000 | 100,000 | 1,000,000 | 5,000,000 | 999,999,999
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
How do you store your rules? Are you able to differentiate between high and low range values independently?
If so a simple loop would do it.
1. Sort rules by start range
2. for each rule do
     if currentrule.start == lastrule.end + 1 then OK
     else fail
3. Check that lastrule.end = 999999
brianmfallsAuthor Commented:
They are separate, and I am already validating for gaps, overlaps, and illegal rules.  The question is more along the lines of how do we force the user to set up the ranges for each condition properly prior to them navigating away from the rule.
Julian HansenCommented:
Well if they have not completed the sequence they can't complete the process - I thought you mentioned something about having a button disabled that is only enabled once the gaps are filled?
brianmfallsAuthor Commented:
I did mention that.  But that was under "So far, my thoughts are along these lines:"  That's part of the solution I'm thinking about implementing.
Julian HansenCommented:
That's part of the solution I'm thinking about implementing.
Good thinking - go with that possibly with a message area explaining why the button is grayed out

"You have not completed all price ranges"

Or event better

"You have not completed all price ranges you have omitted the following

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.