CSCI-121 Assignment #2
Topics Reinforced
- HTML forms (from Lab 3)
- JavaScript Functions
- JavaScript Conditional Statements
- 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:
- Fix your lab3.html file, if needed, so that it is correct and working.
- If needed, read about the Document Object Model (DOM) in your book and/or online at http://www.w3schools.com/js/js_htmldom.asp
- Author a new file named: assignment2.html
- Note that assignment2.html should be a copy of your completed/corrected lab3.html file.
- Following are specific instructions that should be followed:
- Within SCRIPT tags in the document HEADER author a function called: checkFields()
- Within checkFields() use if, else if, else to check each of the text form field values.
- 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.
- If all fields have some text then checkFields() should submit the form by calling the submit() of your form: e.g. document.[formName].submit();
- The checkFields() function should return true if the form is submitted else it should return false.
- Link the checkFields() function with the form via the onSubmit attribute of the form itself.
- 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.
- Upload the assignment2.html file to your google drive and share it with me: thomas.rogers@millersville.edu
- Assignment due by: This assignment is due by midnight, Sunday October 16th.