Homework assignment #3.
In this assignment you need to demonstrate your ability to use JavaScript to check values of input elements. You
need to add JavaScript code to your input form to perform the following:
- Once the user clicks on the Submit button your code first should check that:
- The date is not empty and not equal the format string (mm/dd/yyyy)
- The time is not empty and not equal the format string (hh:mm)
- The title of the picture is not empty
- The file name is not empty either
If at least one condition is violated, your code should:
- Display an error message with the alert() method
- Print the error and an error message next to the element that violates the requirements
- Get this element the focus
- Don't let the default submit handler to run
- Once the user clicks on the Back button, it should be sent back to the previous page. Please note,
that you really need to get back to the previous page in history, not just send the user to your home page.
- Once the user clicks on an input element with format string in there, the
format string should disappear. Note,
that if user entered some information in the input element, then next click on the same element should not
result in removing that information.
- If the user jumps from an element that used to have a format string away to another element, then you need to
restore the format string, but only under the condition that user hasn't enter any information in the field.
- For the two elements Date and Time you need the keyPressed handler defined
to let the user pressed only the characters that are allowed in the text box according the format string.