• Sandy (unregistered)

    The real wtf is that three spaces is ok.

  • Kluge Doctor (unregistered)

    What I wouldn't give for a TRIM function...

    Hey, wait...!!!!

  • Ruben (unregistered)

    Unbelievable that such programmers get serious jobs...

  • FooLman (unregistered)

    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid. How would you code that? :)

  • (cs)

    Screening for basic programming skill during the interview?! Don't be silly. If he says he can code, he can code. The code is bad? But it works. Maintenance? I have deadlines to keep, I can't be bothered to think about the future. Just stop bothering me and go code stuff. Mental note: fire that guy, he has a negative attitude.

  • GordonB (unregistered) in reply to FooLman

    With a regular expression.

  • John Doe (unregistered) in reply to FooLman
    FooLman:
    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid. How would you code that? :)
    Simple: use a Regex! :)
  • AdT (unregistered)

    The real..., ok, let's say another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space. He should have used non-breaking spaces (  if the forum software lets me enter that. :-p )

  • Anon Fred (unregistered)

    ooh, ooh, can i be the first to point out how three spaces looks like one space in HTML!?!!11one

  • meh (unregistered) in reply to Sandy
    Sandy:
    The real wtf is that three spaces is ok.
    If that is the case, what's the false/non-real/unreal wtf?
  • Anon Fred (unregistered) in reply to Anon Fred

    oooh, AdT beat me. :( :( :(

  • [ICR] (unregistered) in reply to FooLman
    FooLman:
    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid. How would you code that? :)
    if(!IsValidInput(txtloginname.Text))
    {
        lblloginMessage.Visible=true;
        lblloginMessage.Text = "Please Enter the User Id";
        return;
    }
    
    if(!IsValidInput(txtcompanyname.Text))
    {
        lblloginMessage.Visible=true;
        lblloginMessage.Text = "Please Enter the Company";
        return;
    }
    

    ... }

    public static bool IsValidInput(string text) { return !(text == "" || text == " " || text == " "); }

    Yes it uses double negation, but I prefer to think in terms of "Is this valid" rather than "Is this invalid".

  • (cs) in reply to FooLman

    With a loop, of course! (C++ RULZ, VB for kiddidz HA!!!)

    bool b = true;
    for (int i = 0; i < strlen(s); i++) {
     if (s[i] != ' ') {
      b = false;
      goto GOOD; // VERY IMPORTANT 4 SPEED! remove this and puppy die!
     }
    }
    if (b) {
     // \a*3 = VERY laud BEEEP
     return "\a\a\aYou have error!!!\n";
    }
    // Stpuid GCC give error label end of block. I wrote clever trick to shut up compiler.
    GOOD: b = !!b;
    
  • (cs)

    My buddy Darrell " " Simpkins always uses his nickname as his login id on websites. Not sure what he would do here. He's almost as bad as Smitty "Drop Users" Holmes.

  • (cs)

    The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P

  • (cs) in reply to AdT
    AdT:
    The real..., ok, let's say another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space. He should have used non-breaking spaces (  if the forum software lets me enter that. :-p )

    Damn you and your beating everyone to the Alex-bashing!

  • (cs)

    I wonder what the problem was, that Telly was asked to solve.

    I note that their label controls have a special naming convention: dromedary camel case.

  • (cs)

    I'd also like to point out that not only could   be used, but

     as well.

  • Sean (unregistered) in reply to Arancaytar
    Arancaytar:
    The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P

    There should be a prize for finding the real WTF.

  • (cs)

    i r 1337 hax0rz, i r try break syst3m with 2 spaces... ohnoes! they check for it! i r deefeeted :(

  • (cs) in reply to AdT
    AdT:
    another WTF is that the title is supposed to contain 4 spaces but Alex forgot about merging of consecutive whitespace characters in HTML so virtually every browser will only display one space.

    He's not alone, apparently.

  • (cs) in reply to morpcat
    morpcat:
    I'd also like to point out that not only could   be used, but
     as well.
    Not inside <title> ...
  • (cs) in reply to Zecc
    Zecc:
    morpcat:
    I'd also like to point out that not only could   be used, but
     as well.
    Not inside <title> ...

    It occurs once within <title>, once within the page. He should be using   for <title>, but leave the three spaces in the body. That way, he can add a client-side script to the page to hardcode <pre> in as the page is generated.</p> </title>

  • (cs)

    WHAT ARE YOU DOING? The virtual crowd hates you! They want more blank spaces!

    I guess the guy was paid by the character, not by usability of the product.

  • rbonvall (unregistered) in reply to GordonB
    GordonB:
    With a regular expression.

    Shhhh, don't mention it. Now someone will quote Zawinski.

  • Bartman (unregistered)

    This is such an obvious WTF that even I got it after the first reading. That is some scary shitizzle fo shizzle...yo

    Captcha is "poindexter" you busters

  • Someone (unregistered)

    I don't get it, I write code like that all the time.... ;-)

  • Tp (unregistered)

    This guy isnt just a bad coder, he is also stupid. Not knowing that this can be done with regex makes him a bad coder. Not seeing that the functionality he is implementing is completly bonko-bonko, is just brilliantly moronic.

  • Bob (unregistered) in reply to [ICR]
    [ICR]:
    FooLman:
    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid. How would you code that? :)
    if(!IsValidInput(txtloginname.Text))
    {
        lblloginMessage.Visible=true;
        lblloginMessage.Text = "Please Enter the User Id";
        return;
    }
    
    if(!IsValidInput(txtcompanyname.Text))
    {
        lblloginMessage.Visible=true;
        lblloginMessage.Text = "Please Enter the Company";
        return;
    }
    

    ... }

    public static bool IsValidInput(string text) { return !(text == "" || text == " " || text == " "); }

    Yes it uses double negation, but I prefer to think in terms of "Is this valid" rather than "Is this invalid".

    Wow, just wow.... and when the requirements change comes down that companyname has a different rule than loginname, and some weak programmer modifies the isValidInput routine without proper testing.. Wait.. that's next week's WTF..

  • Cloak (unregistered) in reply to Sean
    Sean:
    Arancaytar:
    The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P

    There should be a prize for finding the real WTF.

    TRWTF is that they write JavaScript but use Microsoft prefixes for the labels and text boxes

  • volpone (unregistered) in reply to FooLman
    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid.
    Then that systems analyst should have his intestines pulled out through this nostrils, onto death.
  • Ed (unregistered) in reply to Bob

    Wait -- so you're actually suggesting that repeating the exact same lines of code multiple times rather than putting them in a function is a superior solution because we should always plan for inept programmers?

    WOW, just WOW WOW WOWEEEE!!

    If you had to plan for the "weak" programmers I used to work with, this little snippet would be 200 lines long.

  • (cs)

    This example lacks recursion, I have instant dislike of it.

  • (cs)

    Since this is obviously Javascript client-side validation*, every "return" should be return false! Otherwise, the form is submitted with bad data and then, what's the point of validating at the client?

    *The demonic shortcomings of client-side validation is a subject for a differnt discussion

  • (cs)

    You know it is a real WTF if I can see it right away.

    I normally read these things over 4 or 5 times (and some comments) before going "oooooh, i see!".

  • Tobby (unregistered)

    Sounds like an XKCD moment...

    "This form still accepts spaces! What are we gonna do?!?"

    "Everybody stand back! I know regular expressions!"

  • (cs)

    The real WTF is that they first set the label visibility, and then text, which leads to unnesessary flickering.

  • Jonneh (unregistered)

    What is with the Constant Viagra ads?

    Is this industry really plagued by ED? I've only just started out :[

  • (cs) in reply to Ruben
    Ruben:
    Unbelievable that such programmers get serious jobs...
    Unless you've been around enough of them in real employment situations, which many of us have. :-(

    Then you just replace "unbelievable" with "frustrating as hell".

  • (cs) in reply to FooLman
    FooLman:
    Have you ever checked the requirements? What if it said: invalid input is empty string, or one or two spaces. Everything else should be considered valid. How would you code that? :)
    Then I suppose the WTF would be in the requirements... :-O
  • (cs) in reply to Jonneh
    Jonneh:
    What is with the Constant Viagra ads?

    Is this industry really plagued by ED? I've only just started out :[

    Yes! It comes from staring at a monitor all day long.

  • (cs)

    The real WTF is that so many people have wasted their brain cells posting "The real WTF is . . ." messages about such a sad little piece of code.

    The fact that it exists is sad enough; let it die with a little bit of dignity!

    Oh . . . wait . . . it never had any . . . my bad.

    Continue the assault.

  • LiquidPT (unregistered) in reply to Cloak
    Cloak:
    Sean:
    Arancaytar:
    The real WTF is that the article title does not use forced nbsp spaces, which causes them to be rendered as a single space (superfluous HTML whitespace is invisible), so I only got the joke after viewing the document source. =P

    There should be a prize for finding the real WTF.

    TRWTF is that they write JavaScript but use Microsoft prefixes for the labels and text boxes

    That might be because it's not JS... It's C#. The properties being accessed sure look like server-side control properties to me.

  • LiquidPT (unregistered) in reply to Spectre
    Spectre:
    The real WTF is that they first set the label visibility, and then text, which leads to unnesessary flickering.

    Not if this is server-side C# code...

  • (cs)

    There used to be a major OS back in the old days where you could type "stop" to end any program.

    The OS checked for equality against the strings "stop" and "STOP". But not any variants. So if you typed "Stop" or "STop" or STOp or sTOP or stOP or stoP it would continue on.

    Or StoP or SToP or STOp.

  • Mogri (unregistered) in reply to snoofle
    snoofle:
    Jonneh:
    What is with the Constant Viagra ads?

    Is this industry really plagued by ED? I've only just started out :[

    Yes! It comes from staring at a monitor all day long.

    This is probably the worst demographic for marketing Viagra: most programmers are young and many have trouble getting laid.

  • Velko (unregistered) in reply to ParkinT
    ParkinT:
    Since this is obviously Javascript client-side validation*, every "return" should be return false! Otherwise, the form is submitted with bad data and then, what's the point of validating at the client?

    *The demonic shortcomings of client-side validation is a subject for a differnt discussion

    IMHO it looks like C# - server-side validation @ASP.NET

  • Anon (unregistered) in reply to T $
    T $:
    This example lacks recursion, I have instant dislike of it.
    Good point. How about this validation function as a replacement (done in JavaScript):

    [code]function isValid(str) { if (str.length == 0) return false; if (str.substring(0,1) == " ") if (validate(str.substring(1))) { // Avoids tail recursion! return true; } else { return false; } return true; }

  • (cs) in reply to Mogri
    Mogri:
    snoofle:
    Jonneh:
    What is with the Constant Viagra ads?

    Is this industry really plagued by ED? I've only just started out :[

    Yes! It comes from staring at a monitor all day long.

    This is probably the worst demographic for marketing Viagra: most programmers are young and many have trouble getting laid.

    That's beacuse they spend so much time spanking the monkey that it won't come out to play any more; hence the need for Viagra!

  • Franz Kafka (unregistered) in reply to akatherder
    akatherder:
    My buddy Darrell " " Simpkins always uses his nickname as his login id on websites. Not sure what he would do here. He's almost as bad as Smitty "Drop Users" Holmes.

    wait, is that Drop users or '; drop users;--?

Leave a comment on “What If Someone Types In " "?”

Log In or post as a guest

Replying to comment #:

« Return to Article