Validation Time Travel

Posted by AgileCoder on April 8, 2009

On one of the primary web applications I maintain we have real-time help available to clients through an online chat application.  Usually when one of the chat line workers gets an interesting bug report they IM me and I try to fix the problem.

For weeks now I have occasionally been getting questions about our date validation. Specifically, we have people entering today's date and getting told that the date they have to enter must be today or earlier.  We have about 35 places where you can enter a date and the business requirement actually is that the date entered be 'today' or earlier.  We validate this on the server side, but also on the client using the JavaScript function show below. 

//Validate Past date
//---------------------------------------------//
function validatePastDate (control, sFieldName) 
{
    var c = document.getElementById(control);
    if (c != null ) 
    {
    //validate hasDate and isDate snipped//
        var d = new Date();
        var now = new Date();
        if(d.setTime(Date.parse(c.value, "n/j/y")) > now) 
        {
          sErr = sFieldName + " '" + c.value + "' must be a date earlier than today. \n"; 
        }
    }
    return sErr;    
}

Since the bug was opened in our issue database four different testers have tried to replicate it and none have been successful.  Yesterday I got pinged on IM and told that the 'funny date thing' was happening again.

I dropped everything and decided it was time to fix this once and for all.  I poured over the code, looking at the function and everywhere it was called.  No luck.  I ran it from my development box and from the beta server.  No dice.  I fired up an ancient desktop box that was kicking around and all of a sudden...ERROR!

Then I looked in the bottom right hand corner of the screen and noticed that it was 3:06 AM.  Bingo!  When I double-clicked the clock I discovered that the system date on that computer was 4/1/09, not 4/6/09.  It's clear now, but we all overlooked that

var now = new Date(); 

would report the client's system time to the client side validation...



cialis generika kamagra australia cialis preise cialis kaufen cialis bestellen levitra generika viagra online kaufen kamagra bestellen cialis generika kamagra oral jelly kamagra 100mg prix cialis cialis generique kamagra gel viagra prix viagra pour homme acheter cialis kamagra prix viagra pas cher cialis 20mg levitra 20
Levitra Generika kaufen Kaufen Levitra Generika Online Cialis ohne Rezept kaufen Viagra online Viagra Generika kaufen Cialis Soft Tabs kaufen Sildenafil kaufen Apcalis Oral Jelly kaufen Viagra Soft Tabs bestellen Cialis Original kaufen Viagra bestellen Viagra bestellen Propecia Generika kaufen Viagra und seine Analoga Original Testpakete Levitra und Kamagra Erfahrungen Viagra Soft Tabs Kamagra kaufen
kamagra kopen in de winkel viagra werking cialis kopen in nederland cialis bijwerkingen kamagra bijsluiter levitra bijwerkingen viagra kopen apotheek cialis erfaring cialis i norge viagra effekt hva er kamagra viagra nettbutikk levitra eller cialis kamagra gel comprar cialis efeitos secundarios viagra farmacia cialis bula viagra infarmed levitra comprimidos cialis vs viagra cialis flashback kamagra tjejer kamagra effekt levitra fass kamagra oral jelly opiniones levitra generico precio cialis venta kamagra sobres cialis efectos secundarios
Levitra Soft Cialis Professional Levitra Original Cialis Daily Red Viagra Cialis Jelly Acheter Levitra Viagra Professional Viagra Gold - Vigour Kamagra Jelly Viagra pour femme viagra kaufen cialis kaufen Erektile Dysfunktion Viagra Professional Viagra Jelly cialis online kopen Levitra Soft viagra voor vrouwen Viagra Soft
Prezzo Levitra Acquisto Red Viagra Acquisto Cialis Disfunzione Erettile Dopo Prostatectomia Radicale Acquisto Propecia Cialis Generico Viagra Originale senza ricetta Comprare Red Viagra Comprare Levitra Generico On Line Comprare Levitra Online Disfunzione Erettile Blocco Psicologico Levitra Vendita Comprare Propecia Acquisto Female Viagra Acquisto Cialis Jelly Viagra Super Active Levitra Originale Viagra online Levitra Compresse Divisibili Disfunzione Erettile Ecografia
Viagra Soft kamagra oral jelly cialis generisk viagra online viagra online Generisk Viagra Cialis Online Kvinnor Cialis Generisk Cialis Kvinnor Viagra Cialis Super Active Cialis soft viagra apoteket Kamagra Cialis Soft Viagra sverige Kamagra Gel Viagra Soft kamagra oral jelly Kamagra Online
kamagra gel comprar kamagra cialis pas cher cialis prix viagra generico cialis generico cialis prezzo comprare cialis cialis online viagra online
Levitra Vendita levitra Generico Farmacia On Line Vicenza Comprar Cialis Comprar Cialis comprar Kamagra Cialis Super Active Comprar Levitra Cialis Suisse Acheter Levitra Acheter Propecia viagra schweiz cialis kaufen Kamagra Bestellen erectiepillen kopen Cialis Kopen Viagra Viagra Professional Viagra Jelly cialis online kopen Levitra Soft
nike blazer michael kors Ray ban nike huarache Adidas Scarpe Abbigliamento Asics nike flyknit scarpe converse Scarpe air jordan scarpe da calcio nike free nike cortez nike roshe air max new balance oakley converse Scarpe Adidas scarpe Nike Scarpe louis vuitton Ray ban adidas Adidas superstar longchamp air max Cinture scarpe Puma Puma Scarpe Scarpe nike air max scarpe asics nike air force Saucony polo camicie Polo Ralph Lauren