Wednesday, 10 August 2022

WRITE A JAVASCRIPT TO CHECK WHETHER NUMBER IS POSITIVE NEGATIVE AND ZERO



<html>

<style>


</style> 

<body>

<h3> Positive and Negative Number Checker </h3>

<br/>Enter a Number 

<input type="text" id="num_value" name="num_value" size="5">

<br><br>

<input type="submit" onclick="check_number()" value="Check Number"/>

<br><br>


<script>

 function check_number() {

var num_value= document.getElementById("num_value").value;

if (num_value >0 ) {

document.write("Number is Positive");

}

else if(num_value < 0){

document.write("Number is Negative");

}

else {

document.write("Number is zero");

}




 }

</script>

</body>

</html>

No comments:

Post a Comment