troubleshooting Question

Make buttons required

Avatar of ivan rosa
ivan rosaFlag for United States of America asked on
Web DevelopmentCSSHTMLJavaScript
2 Comments1 Solution122 ViewsLast Modified:
Hi Folks,

I had created this simple form below, my question is how can i make it required to be filled if not input.
And for the select value how can i make it that IF, -select- is still not selected, make it also required?

Thanks for looking


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        function submitButton(frm){
            var form = document.forms.cvapplication;
			var output = '<p>Your submission has been accepted</p>';
            output += '<p>interests: ' + form.interests.value + '</p>';
            output += '<p>state: ' + form.country.value + '</p>';
            form.innerHTML = output;
            }
    </script>

</head>
<body>
        <form name="cvapplication" id="cvapplication">
            <p>Input Your Interests</p>
            <input type="text" name="interests" id="interests" size="40" style="font-style: oblique" required>

            <p>Input Your state</p>
            <select size="1" name="country" id="country" style="font-style: italic">
                    <option value="">- Select -</option>
                    <option value="US">United States</option>
                    <option value="CA">Canada</option>
            </select>

            <input type="button" onclick="submitButton(this.form)" value="Submit" >
        </form>
</body>
</html>
ASKER CERTIFIED SOLUTION
Danilo Andrade
Level 3 Systems Administrator

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros