I am currently using the script below to take my inputs and convert them to what I want with some validation included. I have got my server side validation set up and would like to have some client side also, I have validated the lengths of the inputs but now need to ensure that they only contain numbers. This is for the Variables day, month and year. I have tried using IsNumeric() but to no avail
<script type="text/javascript">
function timeMachine() {
var day = $("#date_day").val();
var month = $("#date_month").val();
var year = $("#date_year").val();
if (day == "" && month == "" && year != ""){
if (year.length != 4){
alert("Please enter a valid year!");
} else{
window.location = "/date/" + year ;
}
} else if (day == "" || month == "" || year == ""){
alert("Please enter a full date!");
} else{
var myDate = new Date(year, month-1, day);
var monthNames = [ "january", "february", "march", "april", "may", "june","july", "august", "september", "october", "november", "december" ];
window.location = "/date/" + year + "/" + monthNames[myDate.getMonth()] + "/" + day;
}
return false;
}
</script>
Thoughts?