Results 1 to 10 of 18

Thread: Ajax and Forms

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Lemme guess, the site you just redid was tables and you're converting them to CSS?
    LOL! That and AJAXIFY it.
    Damn. I should have charged more!
    Well, we cant always expect our clients to pay for our education. You'll have good tools after this one.
    This works, but a bit hackish....
    Yeah.... not a good idea....
    The problem i'm having with using one 'anyerror' var is that when an element is correct, it changes the anyerror back to true.
    Hmmm..... are you sure????
    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.

  2. #2
    charlesh's Avatar
    charlesh is offline Master Glow Jedi
    Join Date
    Aug 2006
    Location
    Atlanta, GA - better than you imagined it would be.
    Posts
    189

    Default

    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;
    By the way, I found out the hard way about variable declaration as it relates to scope in JavaScript. Weird thing is that if you declare a variable with the word 'var' inside a function, it is private. To make it global, drop the var. Strange how that works. Outside a function, variables are global. How 'bout that? Strange and bewildering.

    Anyway, I'm still trying to wrap my head around your way. Give me a little more time with it... and thanks again!

LinkBacks (?)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14