DEV Community

Geekyoda
Geekyoda

Posted on

UI with one input field that accepts only numbers in Javascript

Create a simple UI with one input field that accepts only numbers.

If the user types negative numbers, show "enter a positive value".
If the user types an even number, show the next 3 even numbers.
If the user types an odd number, show the next 3 odd numbers.

Top comments (2)

Collapse
 
nileshrawatau45 profile image
Nilesh Rawat

so how to do it can you answer?

here is my code

function fun(){
var a = document.getElementById("numvalid")

if(a < 1){
   return(document.getElementById("msg").innerHTML= "enter the positive value") 


}
else{
    return 
}
Enter fullscreen mode Exit fullscreen mode

}

console.log(fun())

Collapse
 
aniketmishra profile image
Aniket Mishra

Solution