I have created an HTML multiple choice question. I am facing a problem how to validate it. Below is the HTML code:
<h1>JavaScript is ______ Language.</h1><br>
<form>
<input type="radio" name="choice" value="Scripting"> Scripting
<input type="radio" name="choice" value="Programming"> Programming
<input type="radio" name="choice" value="Application"> Application
<input type="radio" name="choice" value="None of These"> None of These
</form>
<button>Submit Answer</button>
When the user clicks the submit button, there should be an alert that will show a message based on what was selected.
- If no option was selected, the alert box should say
"please select choice answer". - If the "Scripting" option was selected, the alert box should say
"Answer is correct !" - If an option different from "Scripting" is selected, the alert box should say
"Answer is wrong".
I want to create this validation in JavaScript.