1. JavaScript / Говнокод #143

    +29.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    var req_date = document.getElementById('requested_date').value.split('-');
    if (req_date.length!=3 || new Number(req_date[0])<1990 || new Number(req_date[0])>2100
    || new Number(req_date[1])<1 || new Number(req_date[1])>12 || new Number(req_date[2])<1) {
    alert('Requested date is not valid, please re-enter.');
    return false;
    }
    
    var ef_date = document.getElementById('effective_date').value.split('-');
    if (ef_date.length!=3 || new Number(ef_date[0])<1990 || new Number(ef_date[0])>2100
    || new Number(ef_date[1])<1 || new Number(ef_date[1])>12 || new Number(ef_date[2])<1) {
    alert('Effective date is not valid, please re-enter.');
    return false;
    }
    
    var ex_date = document.getElementById('expiration_date').value.split('-');
    if (ex_date.length!=3 || new Number(ex_date[0])<1990 || new Number(ex_date[0])>2100
    || new Number(ex_date[1])<1 || new Number(ex_date[1])>12 || new Number(ex_date[2])<1) {
    alert('Expiration date is not valid, please re-enter.');
    return false;
    }
    
    
            var month_days = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
    
    if (new Number(req_date[0])%4) {
    month_days[1] = 28;
    }
    
    if ((new Number(req_date[2])>month_days[new Number(req_date[1])-1]) ) {
    alert('Requested date is not valid, please re-enter.');
    return false;
    }
    
    if (new Number(ef_date[0])%4) {
    month_days[1] = 28;
    }
    if ((new Number(ef_date[2])>month_days[new Number(ef_date[1])-1]) ) {
    alert('Effective date is not valid, please re-enter.');
    return false;
    }
    
    if (new Number(ex_date[0])%4) {
    month_days[1] = 28;
    }
    if ((new Number(ex_date[2])>month_days[new Number(ex_date[1])-1]) ) {
    alert('Expiration date is not valid, please re-enter.');
    return false;
    }

    и такого там много.. еще на PHP скину

    Запостил: guest, 12 Декабря 2008

    Комментарии (29) RSS

    Добавить комментарий