CS 315 Homework 4: Javascript

Assigned: 16 October 2017   Due: 27 October 2017

This homework problem is to be done individually, not in pairs or other groups. Your completed assignment should be submitted using the Assignment Submission Page.

Your solution should use valid HTML5 syntax. You should validate your pages using the W3 HTML validator and the CSS validator as described in class. Your Javascript code is NOT allowed to use the Prototype Framework for this assignment. Please just use "vanilla" Javascript as discussed in class. Your Javascript should be unobtrusive, as defined in class.

Write an unobtrusive Javascript program that asks the user for a single date string. Your script should use regular expressions to pick out the month, the day and the year. You should write a standardized version of the date (including the day of the week) out to the webpage. If the input is not interpretable as a date (in one of the formats you are required to handle), your program should say that. If the input is not a valid date between January 1, 1950 and December 31, 2049, your program should say that. This means your program should accept February 29, 2016 (since 2016 is a leap year), but not February 29, 2003 (since 2003 is not a leap year). Your program should work for at least the following formats:

Input FormatStandardized VersionComment
9/21/05Wednesday, September 21, 2005 When year is two digits, assume it starts with 20 when digits are between 00 and 49, and assume it starts with 19 when digits are between 50 and 99.
09/21/05Wednesday, September 21, 2005
9/21/2005Wednesday, September 21, 2005 Assume fully specified years should be in the range 1950 to 2049.
09/03/2005Saturday, September 3, 2005
9/3/2005Saturday, September 3, 2005 leading zeros for month and day are allowed but optional
September 21, 2005Wednesday, September 21, 2005 You can assume month name will be fully spelled out.

Notes: