CSCI-121 Assignment #2

Topics Reinforced

  1. HTML forms (from Lab 3)
  2. JavaScript Functions
  3. JavaScript Conditional Statements
  4. Document Object Model (DOM) - self study

Assigment Instructions

Background: In Lab3.html you developed an order submission page for a website. In this assignment you will update that page to make sure that all input text form elements contain data (are not blank) and not allow the form to be submitted if any fields are blank. If each input field of type text has any text within then the form submission should be allowed and occur.

Your instructions and your assignment are to:

  1. Fix your lab3.html file, if needed, so that it is correct and working.
  2. If needed, read about the Document Object Model (DOM) in your book and/or online at http://www.w3schools.com/js/js_htmldom.asp
  3. Author a new file named: assignment2.html
  4. Note that assignment2.html should be a copy of your completed/corrected lab3.html file.
  5. Following are specific instructions that should be followed:
    1. Within SCRIPT tags in the document HEADER author a function called: checkFields()
    2. Within checkFields() use if, else if, else to check each of the text form field values.
    3. For each form field value checked, if it is empty ("") then use the alert method along with a message to indicate the field that is missing.
    4. If all fields have some text then checkFields() should submit the form by calling the submit() of your form: e.g. document.[formName].submit();
    5. The checkFields() function should return true if the form is submitted else it should return false.
    6. Link the checkFields() function with the form via the onSubmit attribute of the form itself.
  6. Test your updated form. Your assignment is correct when it gives a meaningful alert when one of the text inputs is missing and if all are filled it submits correctly.
  7. Upload the assignment2.html file to your google drive and share it with me: thomas.rogers@millersville.edu
  8. Assignment due by: This assignment is due by midnight, Sunday October 16th.