+ 2
Help for Running Code
I donât know what the error is but the code in not running nor showing any errors. Since Iâm a beginner to JS I donât know how to debug either so it would be great help if anyone tell me what the problem is please! Btw thanks for stopping and taking a look at my doubt! Thanks in advance đđđ»đđ» https://code.sololearn.com/Wi7RvF3VY6C2/?ref=app
8 RĂ©ponses
+ 8
Buttons cant submit forms
Change type="button" to type="submit"
+ 6
Of course. I scroll recent posts every day.
+ 3
Thanks man and your code looked simple, nice & crisp đđ»đđ»đ
+ 2
OMG it worked thanks a lot brother @Toni Isotalo đđđ»đđ
+ 2
@Toni Isotalo can I tag you in a question in the near future if I have any doubts please? đđđ
+ 2
Thanks a lot @Toni Isotalo đđ»đ
+ 1
The code is right, the SoloLearn processor that failed. I tried on another and it worked.
+ 1
My version of code:
<!DOCTYPE html>
<html>
<head>
<title>CheckBox Validation</title>
<meta charset="UTF-8"/>
<style>
input {
background-color: orange;
border-color: lightsalmon;
}
</style>
</head>
<body>
<h3>A Form</h3>
<form>
<input type="checkbox" id="javascript" value="JavaScript" />JavaScript<br />
<input type="checkbox" id="angularjs" value="AngularJs" />AngularJS<br />
<input type="checkbox" id="nodejs" value="NodeJs" />NodeJS<br />
<input type="checkbox" id="jquery" value="JQuery" />JQuery<br />
<input type="submit" value="Submit" onclick="validate()"/><br/>
<span id="output"></span>
</form>
<script>
function validate() {
var js = document.getElementById("javascript").checked;
var ajs = document.getElementById("angularjs").checked;
var njs = document.getElementById("nodejs").checked;
var jq = document.getElementById("jquery").checked;
if(js || ajs || njs || jq) {
document.getElementById("output").innerHTML = "Validation Is Successful";
} else {
document.getElementById("output").innerHTML = "Please Select At Least One Programming Language";
}
}
</script>
</body>
</html>