Question

In: Computer Science

Can anyone add a validation function to my html? First, ensure that your form uses at...

Can anyone add a validation function to my html? First, ensure that your form uses at least three of the following field types: check boxes, text boxes, option buttons, selection lists, and text areas. Then, program validation for your form ensuring that users enter values or make selections in all fields, and verifying at least one other aspect of at least one of the fields. Provide appropriate feedback to users when the form fails validation. Test your completed program until all validation works reliably with different combinations of valid and erroneous data.

<------------------------------------------------------------------------------------------------------->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Case Project</title>
<link href="layout.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Lamborghini</h1>
<p><a href='index.html'>Lamborghini</a> <a href='ferrari.html'>Ferrari</a> <a href='bugatti.html'>Bugatti</a> <a href='rollsroyce.html'>Rolls-Royce</a></p>
<hr>
<p><img src='https://vignette.wikia.nocookie.net/pawnstarsthegame/images/6/6e/2003_Lamborghini_Murcielago.png'>The Aventador has been created to anticipate the future, as demonstrated by the use of innovative technology, including a V12 engine and the extensive use of carbon fiber. The authentic design masterpieces together stark dynamism with aggression to produce a cutting edge carbon fiber monocoque. The interior of the Aventador combines high-level technology and luxury equipment with premium-quality materials, skilfully crafted with the expertise characteristic of the finest Italian traditions. A supercar family that has already become a legend in its own right. Discover technical specifications, dimensions, performance, and the detailed features of all the new Lamborghini Aventador models.</p>
  

</script>
</body>
</html>

Solutions

Expert Solution

function validateform(){
var name=document.form.name.value;

var group = document.form.yes;

select = document.getElementById('select');

for (var i=0; i<group.length; i++) {
if (group[i].checked)
break;
}
if (i==group.length)
return alert("No radio button is checked");
alert("Radio Button " + (i+1) + " is checked.");
}


if (name==null || name==""){
alert("Please fill name");
return false;
}else if(!this.form.checkbox.checked){

alert("Please check the box");
return false;
}

else if(select.value)

{return true;}
}

if (document.getElementById("txtarea").value == ""){

        alert("Enter the text");

       document.getElementById("txtarea").focus();

               }

               else {

                   alert(document.getElementById("txtarea_consolidation").value);

               }

<form name = "form" method="post" action="" onsubmit="return validateform()">

   <input type="text" name="name"><br/> <input type="checkbox" name="checkbox" value="check"/>

<input type="radio" id="1" name="yes" value="yes"/>

<select id="select">

<option value="">Choose an option</option>

<option value="option1">Option1</option>

   </select>

<textarea id="txtarea"></textarea><br />

</form>


Related Solutions

Can anyone add a validation function to my html? First, ensure that your form uses at...
Can anyone add a validation function to my html? First, ensure that your form uses at least three of the following field types: check boxes, text boxes, option buttons, selection lists, and text areas. Then, program validation for your form ensuring that users enter values or make selections in all fields, and verifying at least one other aspect of at least one of the fields. Provide appropriate feedback to users when the form fails validation. Test your completed program until...
Create a form using the following HTML elements at a minimum. Style the form in your...
Create a form using the following HTML elements at a minimum. Style the form in your CSS. You do not need to include a form action (i.e. the form doesn't have to do anything - we're designing the front end of the form). textarea textbox input type of "email" select radio button checkbox submit button style at least three elements of your form in your stylesheet, including your submit button Use a comment to delineate the beginning and end of...
I used this code for my first draft assignment. My teacher told me not to add...
I used this code for my first draft assignment. My teacher told me not to add a decrypt function. I have the variable encryptionKey holding 16. I can simply negate encryptionKey with the - in front. Then I make one key change and all the code still works properly. How do I adjust this code? import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store...
can anyone summarize for me the below passage and to add for me some information that...
can anyone summarize for me the below passage and to add for me some information that u get from the below passage Thank You Theory of Reasoned Action stresses the importance of attitudes and intentions in changing a behavior. According to this theory, the most important determinant of behavior is intention.23 Very few actions that produce a healthy outcome happen without ample knowledge and full intention to practice the healthy behavior. Two cognitive processes are at work to develop healthy...
Can anyone explain the complete mechanism of a nitrile with a grignard reagent to form a...
Can anyone explain the complete mechanism of a nitrile with a grignard reagent to form a ketone?
<!DOCTYPE html> <html lang="en"> <head>    <title>Form Display Example</title>    <script type="text/javascript">    function display() {...
<!DOCTYPE html> <html lang="en"> <head>    <title>Form Display Example</title>    <script type="text/javascript">    function display() {    dispWin = window.open('','NewWin','toolbar=no,status=no,width=300,height=200')       message = "<ul><li>NAME:" + document.form1.name.value;    message += "<li>ADDRESS:" + document.form1.address.value;    message += "<li>PHONE:" + document.form1.phone.value;    message += "</ul>";    dispWin.document.write(message); } </script> </head> <body>    <h1>Form Display Example</h1>    <p>Enter the following information. When you press the Display button, the data you entered will be displayed in a pop-up.</p>    <form name="form1" method="get" action="">   ...
Write an HTML file that create the following web page. my first nested list steps of...
Write an HTML file that create the following web page. my first nested list steps of backing a cake Important notes: You should have to copy and paste the “HTML script” as your answer for this question. DON’T take screen shot for your HTML script. It must be editable script. Take a screen shot for your output web page and paste it as a part of your answer.
What are creative ways that you can retain your first employee and ensure you are meeting...
What are creative ways that you can retain your first employee and ensure you are meeting his or her needs? Consider how you can meet or exceed the employee’s “psychological contract.” Also, how would you evaluate the new employee in terms of his or her ability to be a team player?
Free Form Styling ( HTML) Your goal this week is to translate ideas into action. The...
Free Form Styling ( HTML) Your goal this week is to translate ideas into action. The text below is just that, it has no formatting. You need to prepare it for a launch on a web page. It needs a header to identify it as an article about the status of 'Wheat Production in America" (it isn't really). It needs to be formatted for readability and it needs to have one image included that are related to the topic. One...
Free Form Styling ( HTML) Your goal this week is to translate ideas into action. The...
Free Form Styling ( HTML) Your goal this week is to translate ideas into action. The text below is just that, it has no formatting. You need to prepare it for a launch on a web page. It needs a header to identify it as an article about the status of 'Wheat Production in America" (it isn't really). It needs to be formatted for readability and it needs to have one image included that are related to the topic. One...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT