SlideShare uma empresa Scribd logo
1 de 3
How wouuld I try to validate a form that has feel in the blanks and has radio buttons through an
external javascript file.
Solution
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Form</title>
<style>
form{padding: 15px}
label{display: inline-block; text-align: right; width:60px; padding-right:5px;}
input[type=submit]{margin-top: 20px;}
.error{color: red; margin-left: 10px;}
</style>
</head>
<body>
<form action="" method="post" id ="aanmelden">
<div>
<label>Name:</label>
<input type="text" name="name" placeholder="Name">
</div>
<div>
<label>Address:</label>
<input type="text" name="address" placeholder="Address">
</div>
<div>
<label>City:</label>
<input type="text" name="city" placeholder="City">
</div>
<input type="submit" />
</form>
<script>
function removeElementsByClass(className){
elements = document.getElementsByClassName(className);
while(elements.length > 0){
elements[0].parentNode.removeChild(elements[0]);
}
}
function flagError(field, prependText){
var message = prependText + " cannot be left blank";
form[field].insertAdjacentHTML('afterend', '<span class="error">' + message + '</span>');
}
function checkEmpty(field, prependText){
if (form[field].value === ""){
flagError(field, prependText);
isValidSubmission = false;
}
}
function validateForm() {
removeElementsByClass("error");
checkEmpty("name", "First name");
checkEmpty("city", "City");
checkEmpty("address", "Address");
return isValidSubmission;
}
var form = document.getElementById("aanmelden"),
isValidSubmission = true;
form.onsubmit = validateForm;
</script>
</body>
</html>
How wouuld I try to validate a form that has feel in the blanks and ha.docx

Mais conteúdo relacionado

Semelhante a How wouuld I try to validate a form that has feel in the blanks and ha.docx

Javascript basic programs
Javascript basic programsJavascript basic programs
Javascript basic programsDigital Shende
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To PracticeSergey Bolshchikov
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckAnthony Montalbano
 
Building & Breaking Web Forms with Quaid-JS
Building & Breaking Web Forms with Quaid-JSBuilding & Breaking Web Forms with Quaid-JS
Building & Breaking Web Forms with Quaid-JScliener
 
Java script form validation
Java script  form validationJava script  form validation
Java script form validationAbhishekMondal42
 
Practical file(XHTML)web designing
Practical file(XHTML)web designingPractical file(XHTML)web designing
Practical file(XHTML)web designingArtiSolanki5
 
Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Sibananda Panda
 
CSS Selector
CSS SelectorCSS Selector
CSS SelectorCalos Kao
 
Bad Form @ JSConf Asia 2014
Bad Form @ JSConf Asia 2014Bad Form @ JSConf Asia 2014
Bad Form @ JSConf Asia 2014cliener
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDTmrcoffee282
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfinfo750646
 

Semelhante a How wouuld I try to validate a form that has feel in the blanks and ha.docx (20)

phptut2
phptut2phptut2
phptut2
 
Html forms
Html formsHtml forms
Html forms
 
16-DOMTree.pptx
16-DOMTree.pptx16-DOMTree.pptx
16-DOMTree.pptx
 
5.1 html lec 5
5.1 html lec 55.1 html lec 5
5.1 html lec 5
 
Javascript basic programs
Javascript basic programsJavascript basic programs
Javascript basic programs
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To Practice
 
logincode carasen12
logincode carasen12logincode carasen12
logincode carasen12
 
Lect# 1 html part ii
Lect# 1 html part iiLect# 1 html part ii
Lect# 1 html part ii
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Building & Breaking Web Forms with Quaid-JS
Building & Breaking Web Forms with Quaid-JSBuilding & Breaking Web Forms with Quaid-JS
Building & Breaking Web Forms with Quaid-JS
 
WIT lab programs.docx
WIT lab programs.docxWIT lab programs.docx
WIT lab programs.docx
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Java script form validation
Java script  form validationJava script  form validation
Java script form validation
 
Practical file(XHTML)web designing
Practical file(XHTML)web designingPractical file(XHTML)web designing
Practical file(XHTML)web designing
 
Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Rounded Shaped Box Example 1
Rounded Shaped Box Example 1
 
CSS Selector
CSS SelectorCSS Selector
CSS Selector
 
assignment 8.pdf
assignment 8.pdfassignment 8.pdf
assignment 8.pdf
 
Bad Form @ JSConf Asia 2014
Bad Form @ JSConf Asia 2014Bad Form @ JSConf Asia 2014
Bad Form @ JSConf Asia 2014
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDT
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdf
 

Mais de hamblymarta

Choose a piece of children's-adolescent media from any era and analyze.docx
Choose a piece of children's-adolescent media from any era and analyze.docxChoose a piece of children's-adolescent media from any era and analyze.docx
Choose a piece of children's-adolescent media from any era and analyze.docxhamblymarta
 
Complete parts (a) and (b) below- The number of dogs per household in.docx
Complete parts (a) and (b) below- The number of dogs per household in.docxComplete parts (a) and (b) below- The number of dogs per household in.docx
Complete parts (a) and (b) below- The number of dogs per household in.docxhamblymarta
 
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docx
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docxComider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docx
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docxhamblymarta
 
Combining estimates with projections of likely events such as turnover.docx
Combining estimates with projections of likely events such as turnover.docxCombining estimates with projections of likely events such as turnover.docx
Combining estimates with projections of likely events such as turnover.docxhamblymarta
 
Christine Danes has asked Dave and Mike to help her move into a new ap.docx
Christine Danes has asked Dave and Mike to help her move into a new ap.docxChristine Danes has asked Dave and Mike to help her move into a new ap.docx
Christine Danes has asked Dave and Mike to help her move into a new ap.docxhamblymarta
 
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docx
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docxCody is trying to explain to Sarah that one advantage enjoyed by plant.docx
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docxhamblymarta
 
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docx
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docxCombining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docx
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docxhamblymarta
 
Code needed in C++ Input and formatted output- Right-facing arrow Give.docx
Code needed in C++ Input and formatted output- Right-facing arrow Give.docxCode needed in C++ Input and formatted output- Right-facing arrow Give.docx
Code needed in C++ Input and formatted output- Right-facing arrow Give.docxhamblymarta
 
Class problem 5 -Animal personality- has been defined as consistent di.docx
Class problem 5 -Animal personality- has been defined as consistent di.docxClass problem 5 -Animal personality- has been defined as consistent di.docx
Class problem 5 -Animal personality- has been defined as consistent di.docxhamblymarta
 
Class Discussion - Guest Speaker - Laura Sonderup Q1- From your exper.docx
Class Discussion - Guest Speaker - Laura Sonderup Q1-  From your exper.docxClass Discussion - Guest Speaker - Laura Sonderup Q1-  From your exper.docx
Class Discussion - Guest Speaker - Laura Sonderup Q1- From your exper.docxhamblymarta
 
Choose all that apply- Which of the following proteins would have an E.docx
Choose all that apply- Which of the following proteins would have an E.docxChoose all that apply- Which of the following proteins would have an E.docx
Choose all that apply- Which of the following proteins would have an E.docxhamblymarta
 
Choose all that apply- Which of the following is something that all ce.docx
Choose all that apply- Which of the following is something that all ce.docxChoose all that apply- Which of the following is something that all ce.docx
Choose all that apply- Which of the following is something that all ce.docxhamblymarta
 
Choose every statement that is true about the cytoplasm- Cytoplasm can.docx
Choose every statement that is true about the cytoplasm- Cytoplasm can.docxChoose every statement that is true about the cytoplasm- Cytoplasm can.docx
Choose every statement that is true about the cytoplasm- Cytoplasm can.docxhamblymarta
 
Case Study- Data-Driven Transformation of Springfield's Police Force S.docx
Case Study- Data-Driven Transformation of Springfield's Police Force S.docxCase Study- Data-Driven Transformation of Springfield's Police Force S.docx
Case Study- Data-Driven Transformation of Springfield's Police Force S.docxhamblymarta
 
Charles Darwin used many different aspects of the natural world as evi.docx
Charles Darwin used many different aspects of the natural world as evi.docxCharles Darwin used many different aspects of the natural world as evi.docx
Charles Darwin used many different aspects of the natural world as evi.docxhamblymarta
 
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docx
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docxChapter 2 notes various problems in the use of ratios and metrics- Whi.docx
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docxhamblymarta
 
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docx
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docxCase -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docx
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docxhamblymarta
 
care plannursing diagnose risk for evidenced by prostatis nursing dia.docx
care plannursing diagnose risk for evidenced by prostatis  nursing dia.docxcare plannursing diagnose risk for evidenced by prostatis  nursing dia.docx
care plannursing diagnose risk for evidenced by prostatis nursing dia.docxhamblymarta
 
Can you please help me answer these two multiple choice questions- Tha.docx
Can you please help me answer these two multiple choice questions- Tha.docxCan you please help me answer these two multiple choice questions- Tha.docx
Can you please help me answer these two multiple choice questions- Tha.docxhamblymarta
 
can someome please write the init method please This interface defines.docx
can someome please write the init method please This interface defines.docxcan someome please write the init method please This interface defines.docx
can someome please write the init method please This interface defines.docxhamblymarta
 

Mais de hamblymarta (20)

Choose a piece of children's-adolescent media from any era and analyze.docx
Choose a piece of children's-adolescent media from any era and analyze.docxChoose a piece of children's-adolescent media from any era and analyze.docx
Choose a piece of children's-adolescent media from any era and analyze.docx
 
Complete parts (a) and (b) below- The number of dogs per household in.docx
Complete parts (a) and (b) below- The number of dogs per household in.docxComplete parts (a) and (b) below- The number of dogs per household in.docx
Complete parts (a) and (b) below- The number of dogs per household in.docx
 
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docx
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docxComider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docx
Comider a pond or tiver adfacent to a higpo iawn in Arrica- The water.docx
 
Combining estimates with projections of likely events such as turnover.docx
Combining estimates with projections of likely events such as turnover.docxCombining estimates with projections of likely events such as turnover.docx
Combining estimates with projections of likely events such as turnover.docx
 
Christine Danes has asked Dave and Mike to help her move into a new ap.docx
Christine Danes has asked Dave and Mike to help her move into a new ap.docxChristine Danes has asked Dave and Mike to help her move into a new ap.docx
Christine Danes has asked Dave and Mike to help her move into a new ap.docx
 
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docx
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docxCody is trying to explain to Sarah that one advantage enjoyed by plant.docx
Cody is trying to explain to Sarah that one advantage enjoyed by plant.docx
 
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docx
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docxCombining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docx
Combining Prehension and Propulsion- The Foot of Ardipithecus ramidus.docx
 
Code needed in C++ Input and formatted output- Right-facing arrow Give.docx
Code needed in C++ Input and formatted output- Right-facing arrow Give.docxCode needed in C++ Input and formatted output- Right-facing arrow Give.docx
Code needed in C++ Input and formatted output- Right-facing arrow Give.docx
 
Class problem 5 -Animal personality- has been defined as consistent di.docx
Class problem 5 -Animal personality- has been defined as consistent di.docxClass problem 5 -Animal personality- has been defined as consistent di.docx
Class problem 5 -Animal personality- has been defined as consistent di.docx
 
Class Discussion - Guest Speaker - Laura Sonderup Q1- From your exper.docx
Class Discussion - Guest Speaker - Laura Sonderup Q1-  From your exper.docxClass Discussion - Guest Speaker - Laura Sonderup Q1-  From your exper.docx
Class Discussion - Guest Speaker - Laura Sonderup Q1- From your exper.docx
 
Choose all that apply- Which of the following proteins would have an E.docx
Choose all that apply- Which of the following proteins would have an E.docxChoose all that apply- Which of the following proteins would have an E.docx
Choose all that apply- Which of the following proteins would have an E.docx
 
Choose all that apply- Which of the following is something that all ce.docx
Choose all that apply- Which of the following is something that all ce.docxChoose all that apply- Which of the following is something that all ce.docx
Choose all that apply- Which of the following is something that all ce.docx
 
Choose every statement that is true about the cytoplasm- Cytoplasm can.docx
Choose every statement that is true about the cytoplasm- Cytoplasm can.docxChoose every statement that is true about the cytoplasm- Cytoplasm can.docx
Choose every statement that is true about the cytoplasm- Cytoplasm can.docx
 
Case Study- Data-Driven Transformation of Springfield's Police Force S.docx
Case Study- Data-Driven Transformation of Springfield's Police Force S.docxCase Study- Data-Driven Transformation of Springfield's Police Force S.docx
Case Study- Data-Driven Transformation of Springfield's Police Force S.docx
 
Charles Darwin used many different aspects of the natural world as evi.docx
Charles Darwin used many different aspects of the natural world as evi.docxCharles Darwin used many different aspects of the natural world as evi.docx
Charles Darwin used many different aspects of the natural world as evi.docx
 
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docx
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docxChapter 2 notes various problems in the use of ratios and metrics- Whi.docx
Chapter 2 notes various problems in the use of ratios and metrics- Whi.docx
 
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docx
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docxCase -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docx
Case -#2- Royal Bank of Canada v- Head West Energy Inc-- 2007 ABQB 154.docx
 
care plannursing diagnose risk for evidenced by prostatis nursing dia.docx
care plannursing diagnose risk for evidenced by prostatis  nursing dia.docxcare plannursing diagnose risk for evidenced by prostatis  nursing dia.docx
care plannursing diagnose risk for evidenced by prostatis nursing dia.docx
 
Can you please help me answer these two multiple choice questions- Tha.docx
Can you please help me answer these two multiple choice questions- Tha.docxCan you please help me answer these two multiple choice questions- Tha.docx
Can you please help me answer these two multiple choice questions- Tha.docx
 
can someome please write the init method please This interface defines.docx
can someome please write the init method please This interface defines.docxcan someome please write the init method please This interface defines.docx
can someome please write the init method please This interface defines.docx
 

Último

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Último (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

How wouuld I try to validate a form that has feel in the blanks and ha.docx

  • 1. How wouuld I try to validate a form that has feel in the blanks and has radio buttons through an external javascript file. Solution <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Form</title> <style> form{padding: 15px} label{display: inline-block; text-align: right; width:60px; padding-right:5px;} input[type=submit]{margin-top: 20px;} .error{color: red; margin-left: 10px;} </style> </head> <body> <form action="" method="post" id ="aanmelden"> <div> <label>Name:</label> <input type="text" name="name" placeholder="Name"> </div> <div> <label>Address:</label> <input type="text" name="address" placeholder="Address"> </div> <div> <label>City:</label> <input type="text" name="city" placeholder="City"> </div> <input type="submit" />
  • 2. </form> <script> function removeElementsByClass(className){ elements = document.getElementsByClassName(className); while(elements.length > 0){ elements[0].parentNode.removeChild(elements[0]); } } function flagError(field, prependText){ var message = prependText + " cannot be left blank"; form[field].insertAdjacentHTML('afterend', '<span class="error">' + message + '</span>'); } function checkEmpty(field, prependText){ if (form[field].value === ""){ flagError(field, prependText); isValidSubmission = false; } } function validateForm() { removeElementsByClass("error"); checkEmpty("name", "First name"); checkEmpty("city", "City"); checkEmpty("address", "Address"); return isValidSubmission; } var form = document.getElementById("aanmelden"), isValidSubmission = true; form.onsubmit = validateForm; </script> </body> </html>