Be guilty! Be VERY guilty! LOL!
As for the code, no its not the same.
Your code doesnt tell us if there were any errors.
Only if the 2 are different. So ultimately, it gives us little useful info.
First, in the spirit of doing it right we should really be doing
Code:
anyerrors=(ok==false ? true : anyerrors);
because ok could be null, which would trigger it.
That code is a one line version of an if/else, but in this version, the 'else' is required.
Long version:
Code:
if (ok==false){
anyerrors=true;
} else {
// Do nothing
}
Since anyerrors is a flag to tell us if there were EVER any errors in ANY of the validations, we set it false, and we loop through ALL validation to see if any come back false which is when we set it true to indicate there was an error. By maintaining your functions to return a proper true or false, you can continue to use them individually when a user changes a single value before submitting.
You could also do something like this:
Code:
anyerrors=0;
ok=...
if (ok==false)
anyerrors++;
ok=...
if (ok==false)
anyerrors++;
alert('# of errors: '+anyerrors)
I opted for a simple "is there or is there not any errors" because your validation seems to use dhtml nicely to indicate right on the field itself that there is one or more error.
And, yes, I am a solo act.