In a JavaScript file named myScript.js create a JavaScript function, getClasses(elem), that returns the classes of any HTML element as an array. For example if the function was given the following element:
<p class=”foo bar”>HI</p>
It would return [“foo”, “bar”].
Create a JavaScript function, addClass(elem, className), that adds a class to the given element’s class list. If the element doesn’t have the class attribute the function should add it.
Create a Bootstrap styled HTML document named demo_form.html with the following form in it:
<form name=”myForm” action=”demo_form.html” onsubmit=”return validateForm()” method=”get”>
<div class=”form-group”>
<label for=”username”>User name: </label>
<input type=”text” name=”name” id=”username”>
</div>
<div class=”form-group”>
<label for=”email”>Email: </label>
<input type=”email” name=”email” id=”email”>
</div>
<div class=”form-group”>
<label for=”password”>Password: </label>
<input type=”password” name=”password” id=”password”>
</div>
<div class=”form-group”>
<label for=”confirm”>Confirm Password: </label>
<input type=”password” name=”confirm” id=”confirm”>
</div>
<input type=”submit” value=”Submit”>
</form>
Write the validateForm function that checks that all text fields have entries and that the Password and Confirm Password entries are the same. If there are any errors have the validateForm function highlight the input field(s) in red and add an error message at the top of the form indicating what the error(s) were.
To be completed before week 5’s first class period.
Email Jack, jacksy (AT) hawaii (DOT) edu, and me, cmoore@hawaii.edu, with with a link to your GitHub repository and the A07 directory where you saved this assignment.
Note: the subject line must have [ICS 415-<section> A07] in the subject. If [ICS 415-<section> A07] is missing, then I might not see the email and you might not get credit for this assignment.