Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a JavaScript assignment, please read carefully. The last person who answ

ID: 3682278 • Letter: T

Question

This is a JavaScript assignment, please read carefully. The last person who answered it left out the second text box, the text area,the extra radio button and the alert on the form. I down voted it and I'm reposting. Create an HTML5 page with JavaScript containing a form that includes 2 textboxes (one for name, one for email address), a textarea, a dropdown box, a set of radio buttons, and a set of checkboxes. The action attribute of the form tag should be an alert displaying the valid information entered into the form. Add JavaScript event handlers to the form to validate the form. If there is a problem, display the problem with the page in some way. Possible ways to do this are: - a pop-up box - displaying the problems in a new window in red text - displaying the problems in red text next to each field Validate that an entry has been made in each form element. Validate that the email address contains an @ sign. Add a second drop down list and make this second one dynamic, i.e. make the choices that appear in the second drop down list depend on what choice is made in the first list. I do down vote for incorrect, unusable answers or answers that are obviously not even close to what I'm asking.

Explanation / Answer

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>JS validation</title>
<script type="text/javascript">
function display()
{
var sex,lang;
var name=document.getElementById('name').value;
var emailid=document.getElementById('emailid').value;
var address=document.getElementById('address').value;
var sex_checked=document.getElementsByName('sex');
if(sex_checked[0].checked)
sex=sex_checked[0].value;
else
sex=sex_checked[1].value;

var lang_checked=document.getElementsByName('lang');

if(lang_checked[0].checked)
lang=lang_checked[0].value;
else
lang=lang_checked[1].value;
var fooditems=document.getElementById('fooditems').value;
var subcategory=document.getElementById('subcategory').value;
alert(" Name:"+name+ " EmailId"+emailid +" Address:" + address

+" Sex:" + sex+" Language:"+lang+" FoodItems

category:"+fooditems+" Sub-Category:"+subcategory);
}
function validate()
{
var emailRegex = /^[A-Za-z0-9._]*@[A-Za-z]*.[A-Za-z]{2,5}$/;
var name=document.getElementById('name').value;
var emailid=document.getElementById('emailid').value;
var address=document.getElementById('address').value;
var msex=document.getElementsByName('sex');
var lang=document.getElementsByName('lang');
var fooditems=document.getElementById('fooditems').value;
var subcategory=document.getElementById('subcategory').value;
if(name=="")
alert("Enter name");
else if(emailid=="")
alert("Enter email id");
else if(!emailRegex.test(emailid))
alert("Enter valid email");
else if(address=="")
alert("Enter address");
else if(!msex[0].checked && !msex[1].checked)
alert("Select gender");
else if(!lang[0].checked && !lang[1].checked)
alert("Select atleast one language");
else if(fooditems=="")
alert("Select food item");
else if(subcategory=="")
alert("Select subcategory of food items");
else return true;
return false;
}
function getitemlist(item)
{
document.getElementById("sub_category").style.display="block";
switch (item)
            {
            case "fruits" :
                document.getElementById("subcategory").options[0]=new

Option("Please select fruits","");
                document.getElementById("subcategory").options[1]=new

Option("apple","apple");
                document.getElementById("subcategory").options[2]=new

Option("banana","banana");
                document.getElementById("subcategory").options[3]=new

Option("mangoes","mangoes");
                break;

            case "vegs" :
                document.getElementById("subcategory").options[0]=new

Option("Please select vegetables","");
                document.getElementById("subcategory").options[1]=new

Option("potato","potato");
                document.getElementById("subcategory").options[2]=new

Option("cabbage","cabbage");
                break;

          default:

document.getElementById("sub_category").style.display="none";
       
                break;
            }
}
</script>
    </head>
<br><body>

    <form name="form1" action="javascript:display()">
<table>
<tr><td>Name:
      <td><input id="name">
     </td>
</tr>
<tr><td>Email Id:
      <td><input id="emailid"></td>
</tr>
<tr><td>Address:
      <td><textarea id=address rows=3 cols=20></textarea></td>
</tr>
<tr><td>Date:
      <td><select id="fooditems">    <option value="">select food items</option>
   <option value="fruits">Fruits</option>
   <option value="vegs">Vegetables</option>
   </select>
      </td>
     <td>
   <div id=sub_category>
            <select name="subcategory" id="subcategory" >
            <option value="">Please select foods</option>
            </select>
   </div>
    </td>
</tr>
<tr><td>Sex:
      <td><input name=sex value=Male type="radio">Male</td>
      <td><input name=sex value=Female type="radio">Female</td>
</tr>
<tr><td>Languages:
      <td><input name=lang value=English type="checkbox">English</td>
      <td><input name=lang value=Spanish

type="checkbox">Spanish</td>
</tr>
<tr><td colspan=2 align=center>
<input type="Submit" value="Submit"/></tr>
</table>
    </form>
    </div>
    </body>
    </html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote