Pin / Number input validator

I recently ran into the following problem:

"We have an application which reads a kind of PIN number (having unlimited digits) from the console (or gui).
We need a simple and elegant algorythm to check if the introduced number does not have the following format i(i+1)(i+2)…(i+n), (eg 123456789)"

Whell the problem is really chalanging, mainly becouse we are talking about numbers having unknown digit count.

After some tinking time I ended up with the the following code:

 

pin_input.gif

 

If you have some other ideas, or just have something to say concerning the presented approach, feel free to comment.

Till next time

Happy coding