Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Seriously? Why write it yourself

Seriously? Why write it yourself

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpjavascriptquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JChrisCompton
    wrote on last edited by
    #1

    Our contractor just discovered a piece of code in a new project written in C# this year (2011) that doesn't use the date validator. And... why would you use three text boxes to collect a date (one each for day/month/year) and then use Javascript to validate it? Oh, and the home grown validation code will accept 14 as a month

    function checkMonth(oMonth) {
    if (parseInt(oMonth.value) != NaN) {
    if (parseInt(oMonth.value) > 12) {
    oMonth.value = parseInt(oMonth.value) - 12;
    }
    }
    else {
    oMonth.value = "";
    }
    }

    and 62 as a valid day

            function checkDay(oDay) {
                if (parseInt(oDay.value) != NaN) {
                    if (parseInt(oDay.value) > 31) {
                        oDay.value = parseInt(oDay.value) - 31;
                    }
                }
                else {
                    oDay.value = "";
                }
            }
    

    Obviously, this person needed a vacation :) P.S. It is just a standard LOB application that doesn't need to accept weird dates.

    B T 2 Replies Last reply
    0
    • J JChrisCompton

      Our contractor just discovered a piece of code in a new project written in C# this year (2011) that doesn't use the date validator. And... why would you use three text boxes to collect a date (one each for day/month/year) and then use Javascript to validate it? Oh, and the home grown validation code will accept 14 as a month

      function checkMonth(oMonth) {
      if (parseInt(oMonth.value) != NaN) {
      if (parseInt(oMonth.value) > 12) {
      oMonth.value = parseInt(oMonth.value) - 12;
      }
      }
      else {
      oMonth.value = "";
      }
      }

      and 62 as a valid day

              function checkDay(oDay) {
                  if (parseInt(oDay.value) != NaN) {
                      if (parseInt(oDay.value) > 31) {
                          oDay.value = parseInt(oDay.value) - 31;
                      }
                  }
                  else {
                      oDay.value = "";
                  }
              }
      

      Obviously, this person needed a vacation :) P.S. It is just a standard LOB application that doesn't need to accept weird dates.

      B Offline
      B Offline
      BillW33
      wrote on last edited by
      #2

      Not knowing that a date validator is available is one thing, but writing such a poor validator is really a coding horror! :(

      Just because the code works, it doesn't mean that it is good code.

      B 1 Reply Last reply
      0
      • B BillW33

        Not knowing that a date validator is available is one thing, but writing such a poor validator is really a coding horror! :(

        Just because the code works, it doesn't mean that it is good code.

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        Yeah I could easily have written the 'primary WTF' (not using the date validator ... I'd probably have used DateTime.TryParse or something), but writing client side validation and then doing it wrong are definitely worthy of this forum.

        J 1 Reply Last reply
        0
        • J JChrisCompton

          Our contractor just discovered a piece of code in a new project written in C# this year (2011) that doesn't use the date validator. And... why would you use three text boxes to collect a date (one each for day/month/year) and then use Javascript to validate it? Oh, and the home grown validation code will accept 14 as a month

          function checkMonth(oMonth) {
          if (parseInt(oMonth.value) != NaN) {
          if (parseInt(oMonth.value) > 12) {
          oMonth.value = parseInt(oMonth.value) - 12;
          }
          }
          else {
          oMonth.value = "";
          }
          }

          and 62 as a valid day

                  function checkDay(oDay) {
                      if (parseInt(oDay.value) != NaN) {
                          if (parseInt(oDay.value) > 31) {
                              oDay.value = parseInt(oDay.value) - 31;
                          }
                      }
                      else {
                          oDay.value = "";
                      }
                  }
          

          Obviously, this person needed a vacation :) P.S. It is just a standard LOB application that doesn't need to accept weird dates.

          T Offline
          T Offline
          TorstenH
          wrote on last edited by
          #4

          looks fine to me! written on 58-15-6831 :laugh:

          regards Torsten I never finish anyth...

          R 1 Reply Last reply
          0
          • B BobJanova

            Yeah I could easily have written the 'primary WTF' (not using the date validator ... I'd probably have used DateTime.TryParse or something), but writing client side validation and then doing it wrong are definitely worthy of this forum.

            J Offline
            J Offline
            JChrisCompton
            wrote on last edited by
            #5

            Our coding standards say "Use Visual Studio validator controls whenever possible to ease maintenance."

            1 Reply Last reply
            0
            • T TorstenH

              looks fine to me! written on 58-15-6831 :laugh:

              regards Torsten I never finish anyth...

              R Offline
              R Offline
              Ra one
              wrote on last edited by
              #6

              What if the month is 25. (25-12=13) :)

              T 1 Reply Last reply
              0
              • R Ra one

                What if the month is 25. (25-12=13) :)

                T Offline
                T Offline
                TorstenH
                wrote on last edited by
                #7

                fine to me - I can handle a 13. pay check :rolleyes:

                regards Torsten I never finish anyth...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups