![]() |
|
||||
|
Quote:
Quote:
Quote:
Quote:
anyerrors=(!ok ? true : anyerrors); What this should do is, set anyerrors to false first then, if we get a 'false' (!ok) from the validation, we set anyerrors to true. If the validation returns tru, then we just do a dummy operation of making anyerrors equal anyerrors. Problem is, if your validation doesn't return anything, I think THAT is the problem. Try this instead anyerrors=(ok==false ? true : anyerrors); This way if you slipped and did not return an explicit true, which I will bet is the issue here, it will explicitly look for a false. !ok is false, OR no value. |
|
||||
|
Jmarc,
I think I did what you mention above, just a bit backhanded way of getting there. First, I set all error vars to "true" that way, each validation function has to explicitly make them true or leave them false: Code:
var usernameerror=true;
var pworderror=true;
var emailerror=true;
var firstnameerror=true;
var lastnameerror=true;
Anyway, I'm still trying to wrap my head around your way. Give me a little more time with it... and thanks again! |
|
||||
|
Backhanded indeed. Not a problem if it works. But not a good idea. 10 or 20 years later (I have software from 1990s still running, so dont kid yourself!) you'll be scratching your, uhhh.... head wondering what in hell you were doing. Oh, and this is where we repeat the DOCUMENTATION mantra....
So, blitzkrieg programming? Fine, but at some point, in your leisure time, try to get it right. True is true, it is not false even if you CAN use it that way. Matt can tell you just how pleased I was when I inherited some perl code that was.... well.... with all the cursing I did over the guys code, I am sure there was an immediate karmic wave that capsized his boat somewhere..... Yeah, var. Wouldnt it be nice if these bums would tell you what was up with that before giving examples? However, var is a lifesaver. How clean is YOUR naming conventions? Nice to name it what you want in a function and NOT have to worry at all with what is going on with naming anywhere else. Keep the spirit. Learning the easy way sucks. Feels nice, but... |
|
||||
|
Now you're making me feel guilty. OK,OK. Here's what I'm going to do -- put it on the list of clean up items for the site - it's working now, but need to come back to it. I'm back to php for the moment and trying to trouble shoot a SQL error for the lost PW script. I am a big believer in doing things right, so I want to get that right as well, just have to digest it a little further.
As far as the "shortcut" in coding for this: Code:
anyerrors=(!ok ? true : anyerrors); Code:
if (anyerrors !=OK){anyerrors=true;}
|
|
||||
|
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); 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
}
You could also do something like this: Code:
anyerrors=0;
ok=...
if (ok==false)
anyerrors++;
ok=...
if (ok==false)
anyerrors++;
alert('# of errors: '+anyerrors)
And, yes, I am a solo act. |
| Thread Tools | |
| Display Modes | |
|
|
|
LinkBack to this Thread: http://glowhost.com/forums/programming-talk/ajax-forms-1441.html
|
||||
| Posted By | For | Type | Date | |
| Ajax and Forms - GlowHost Web Hosting Forums | This thread | Refback | 09-27-2008 10:30 PM | |