Friday, April 23, 2021

Odd and Even Number Checker in JavaScript

 A simple program that I wrote to ask the user to give a number and then the program will check if the given number is odd or even number using JavaScript programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com







Program Listing

<!DOCTYPE html>
<html> 
<head>
<meta charset=utf-8 />
<title>Odd and Even Number Checker in JavaScript </title>
<style type="text/css">
html {
    box-sizingborder-box;
    margin0;
    padding0;
}

body {
    background#fff;
    color#000;
    height100%;
    min-height100vh;
    overflow-yauto;
    padding100px 0;
    text-aligncenter;
    font-familysans-serif;
}

h1:nth-of-type(1) {
    font-size35px;
    line-height35px;
    margin0 0 15px;
}

h2:nth-of-type(1) {
    margin0 0 35px;
}

h2:nth-of-type(2) {
    margin30px 0 20px;
    text-transformuppercase;
    letter-spacing1px;
    font-size30px;
}

a,
input[type="submit"] {
    margin0 0 35px;
    color#fff;
    text-decorationnone;
    padding15px 20px;
    border-radius10px;
    min-width150px;
    background#3CBB9E;
    displayinline-block;
    text-transformuppercase;
    bordernone;
    outlinenone;
    font-size15px;
}

a:hover,
input[type="submit"]:hover {
    opacity0.8;
    color#fff;
    cursorpointer;
}

a:nth-of-type(1) {
    margin-right8px;
}

a:nth-of-type(2) {
    margin-left8px;
}

table {
    margin0 auto;
    border-collapsecollapse;
    border1px solid #000;
}

thead td {
    text-transformuppercase;
    font-weight700;
    background#00334B;
    color#f2f2f2;
}

tbody tr {
    background#fff;
    border-bottom1px solid #00334B;
    color#666666;
}

td {
    padding20px;
}

table a,
table a:hover {
    border-radius5px;
    min-width80px !important;
    padding10px !important;
    margin0 !important;
}

table tr td:nth-child(4a {
    background#2b86c5 !important;
}

table tr td:nth-child(5a {
    background#784ba0 !important;
}

table tr td:nth-child(6a {
    background#ff3cac !important;
}

p,
label,
input[type="text"] {
    font-size15px;
    margin-bottom10px;
}

p {
    font-size20px;
}

label {
    width200px;
    displayinline-block;
    padding15px 0;
    background#3CBB9E;
    color#fff;
    border-top-left-radius30px;
    border-bottom-left-radius30px;
    text-transformuppercase;
    font-size15px;
}

input[type="number"] {
    border0;
    outlinenone;
    padding15px 20px;
    width250px;
    border-top-right-radius10px;
    border-bottom-right-radius10px;
    font-size15px;
    background#eaeaea;
}

form {
    displayblock;
    width350px;
    margin0 auto;
}

input[type="submit"] {
    width100%;
    font-size15px;
}

h1 {
    text-transformuppercase;
    letter-spacing1px;
    color#f5f5f5;
    background#009688;
    padding15px;
    border-radius10px;
    margin0;
    line-height30px;
    font-size35px;
}

</style> 
</head>
<body>
    <h1>Odd and Even Number Checker in JavaScript</h1>
    <script>
        function isEven() {

       //get the input value
             var num = document.getElementById('Val_Num').value;
    if (num%2 == 0)
        
        alert("The given number " + num +  " is even number");
    else
    alert("The given number " + num + " is odd number");
}

function Clear_Text() {

 document.getElementById('Val_Num').value ="";
 document.getElementById('Val_Num').focus();
 

}

    </script>
<form>
<label>Give a Number </label> <input type="number" id="Val_Num" name="Val_Num"/><br>
<br>
<input type="submit" onClick="isEven()" Value="Check" />
<input type="submit" onClick="Clear_Text()" Value="Clear" />
</form>
</p>
</body>
</html>

No comments:

Post a Comment