HW07: JS Form Validation due Mon 13 Oct 23:59

Purpose

In this assignment you will:

Context

In all you do please remember that being a part of CSCI@HSU means DOING THE RIGHT THING.

So, do this assignment in a way that demonstrates integrity, develops competence, is correct, and honors God ... because what we do matters!

Allowed and Disallowed Resources

In completing this assignment you MAY use/access the following resources:

You may NOT use/access:

Failure to abide by these guidelines will result in a zero for the assignment and the incident will be reported to the university provost as a violation of the university academic integrity policy. A second incident of academic dishonesty (whether from this course or another computer science course) will result in an F in the course.

Finish Lab Day Work

If you haven't done so already. Complete your lab day work. Your final form should:

Part 1: Complete the Poem Page Form (12 pts)

Add Radio Buttons to Your Form
Continuing working on the form in poemlayout.html. Add a form element to the form called “Poet Rating” that will provide a set of radio buttons that will allow the poet to rate themselves as one of the following: Beginner, Intermediate, Advanced. The buttons should be attratively arranged and labeled in accordance with your color scheme.

Modify the Poem Type Dropdown
It is common, when creating a drop-down select box to have the first option provide instructions rather than be a valid entry. One reason for this is that sometimes you don't want to have a “default” value, but rather to know that the user has explicitly chosen something. In this case, the first/default entry should say something like: “Select Poem Type ...”.

Validate All Form Elements
Using the same techniques as from the lab day exercise, continue adding form validation to the form as follows:
  • Verify that exactly one radio button in the Poet Rating has been selected. Radio buttons can be a hassle to work with. Rather than checking each one individually based on its id value you can use the .querySelectorAll() command to produce a list of checked values and then inspect the result:
    let checkedRadios = document.querySelectorAll('input[type="radio"]:checked')
    // Remember, this returns an array-like structure that in this case show all the checked
    // radio button.
    
  • Verify that one of the poem types (not ”Select Poem Type ...") has been selected.
  • The Poem Title should be trimmed of trailing and leading whitespace and can contain any characters and should have at least 3 characters.
  • The Poem itself should also be trimmed and should contain at least 10 characters with no restriction on the types of characters.

The error messages should use the same styling and methodology as prescribed in the lab day exercise. Commit your work and push it to GitHub.

Part 2: Add Validation to Personal Site (12 pts)

If you haven't done so already, copy the most recent version of your personal site into the hw07 directory. Now use the same techniques to add trimming, validation, and well-formed error messages to the form on your personal site.

Commit your work and push it to GitHub.