Check Enter no divisible by 5 or not
In this program user checks the logic about numeric value that will it be Division able with 5 or not. To check this declares a variable. And a logic will be used along with the Modulus operator(%).that will be manipulate with the numeric value and control statement (if-else) used if the numeric value is dividable than output will be show true others than false .
course code - --
Just copy and past this in your .html file than open in browser see the result.
<h1>Check Enter no divisible by 5 or not </h1>
<input type="number" placeholder="Enter a number " id="en"/>
<button onclick="check_no();"> Check number</button>
<p id="show_no"> </p>
<script>
function check_no(){
var enter_no = document.getElementById("en").value;
var gettext = document.getElementById("show_no");
if (enter_no%5==0) {
gettext.innerHTML= "Given no divisible by 5";
} else {
gettext.innerHTML="<p style='color:red;'>Given not divisible by 5</p>";
}
}
</script>
0 Comments