|
Due:
Submit on D2L,
and as usual have your a link to your form
available at https://php.radford.edu/~yourUserId/itec325/hw06/index.php.
(No hardcopy needed.)
Note: Points-possible are approximate, and may change somewhat when grading.
We will further improve on server-side-validation/’s Okaymon page by adding client-side validation. Make a copy of your directory from hw051, named hw06/. (cp -pR hw05/ hw06 will Recursively copy directories, preserving timestamps.) Alternately, use any/all of the hw05-soln (or even the hw03-soln).
Be sure to use your named-constants file, for the field-lengths. (1/3 of the points are for that.)
Note that this interacts with our previously-written functions for generating dropdowns and radio-buttons; we now want to have those input tags include a required="required" attribute, and perhaps other attributes. There are several ways to do this, but I suggest a fairly general solution: add a(nother) argument to those functions: an array whose key/value pairs are the additional html attributes you want to have included. Good thing we already wrote a function that can help with this! By making this an optional argument whose default-value is the empty array, we are still backwards-compatible with all our previous test-cases (though you'll want to add another few test cases, to test this new functionality).
Write a separate javascript function which does this:
if the field is too big, it inserts the message-text into a nearby span whose
id is weight-err.
(You may write reportError yourself, or use the version in the notes (with
citation of course).)
Make sure that onsubmit of the form, you also call the validation function for the weight; if it is too large, then the form doesn't get submitted (and the error-message is being shown).
You do not need to have your javascript in an external file, for this homework. In fact, since some of the validation requires info from the constants-file, a pure-external-javascript solution would mean generating that .js — either on each fetch, or a more-static version which you must be sure to regenerate each time okaymon-constants.php is changed.
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |