Seriously? Why write it yourself
-
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.
-
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.
-
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.
-
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.
-
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.
Our coding standards say "Use Visual Studio validator controls whenever possible to ease maintenance."