Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8260037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:59:46+00:00 2026-06-08T02:59:46+00:00

I am currently using Google maps and attempting to use input validation. I require

  • 0

I am currently using Google maps and attempting to use input validation. I require the user to use a number between 0 and 20 to set as a zoom on my location.

Below is the code I am using. The first if statement works perfectly for any number over 20 but the second does not work when I use numbers like 0 and -1 (for instance.)

Any suggestions for fixing this?

function inputIsValid() {

                       console.log("Inside inputIsValid function");

                       //Check for Above 20
                       if (document.getElementById("txtZoom").value  > 20) {
                           alert("Please insertAmount between 0 and 20");
                           document.getElementById("txtZoom").focus();
                           return false;

                           //Check for Number below 0
                           if (document.getElementById("txtZoom").value < 0) {
                               alert("Please insertAmount between 0 and 20");
                               document.getElementById("txtZoom").focus();
                               return false;
                           }
                       }
                   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:59:48+00:00Added an answer on June 8, 2026 at 2:59 am

    The problem is you nested the second check within the first, so it will never be reached. Try this:

    function inputIsValid() {
        var zoomValue = document.getElementById("txtZoom").value;
    
        if (zoomValue > 20 || zoomValue < 0) {
             alert("Please insertAmount between 0 and 20");
             document.getElementById("txtZoom").focus();
             return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Google Maps in order to display current user location. While using
I'm attempting to use the Google geocoder API to enter user's location information directly
I am currently using the google maps' reverse geocoding API to convert long/lat received
I am developing a gis application using Google maps API. Currently I am using
using javascript google-maps api I currently have it setup to remove a maker I
Currently I've been using google's static maps to display maps in a phonegap app
Scenario : I'm currently trying to build a poor man's Google Maps using scripts
I am currently doing a tracking application and am using Google maps fusion table
I'm currently developing a website and part of it involves using Google Maps. I'd
We are using Google maps API V3 and we have a set of boundries

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.