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

  • Home
  • SEARCH
  • 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 6547251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:48:26+00:00 2026-05-25T11:48:26+00:00

i hate asking for help as i would rather figure things for myself, or

  • 0

i hate asking for help as i would rather figure things for myself, or learn from what others have posted or already asked and solved. as such this is my first post on here!

This is either really really simple and im over complicating things or im going about it the wrong way. ive been searching everywhere for over 2 hours now. im not exactly a noob at js but i am still sort of new,i would say learning, ameteur?? anywho….

what i am trying to do:

so i have a number input box <input type="number" maxlength="4" .../> where a user will enter a 4 digit number (needs to be 4 digits) from 100 to 8000. so obviously 100 to 999 would be 0100 – 0999.

no problem so far, i can just use a string to pass the variable through as 4 digits.

the problem i have is that i need to add certain conditions to validate the input. one condition is bugging me. this is what i have so far:

(var x is already set to the form and number input box)

if (x=="" || isNaN(x) || x.length!== 4 && x< 0100 || x>8000)
{alert(please enter the correct amount!}
else {run rest of function}

so they all work execpt for:x<0100

if the user enters 99 it flags up because it is not 4 digits and if they enter 0099 it accepts it and runs the rest of the function code.

i just need it to alert for any amount from 0001 to 0099.

i found another post, How to make 8 digit number in javascript? , sort of relevant but the guy just wants to output a number padded with zeros. i think one of the solutions (code below) may be of use to me but as i am rather tired, brain frazzled and new i cant solve it:

var i = (100).toPrecision(8).split('.').reverse().join('');

i would start by editing it to:

var i = (x).toPrecision(4).split('.').reverse().join('');

(but would this only work if they typed 99 not 0099…if ya see what i mean)

i think it would be like a reverse of the code (split 0099 to 99.00) , and then the statement would be: if(.... && i<==99 || ....) but idk how to write it in JS…

ok so do ya see how this is messing with me mind, being a semi/quarterly noob and all!!

sorry its not formatted correctly and so long, i havent grasped how to use the code functions…

and thanks for your patience in reading this (if you got this far hehe).

THANKS IN ADVANCE

Slappy-x

  • 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-05-25T11:48:26+00:00Added an answer on May 25, 2026 at 11:48 am

    The number 0100 will be treated as octal value (which is 64 in decimal).

    I think you would do fine by just comparing against strings:

    x < "0100" || x > "8000"
    

    Otherwise you have to convert the x into a number and compare it against 100:

    +x < 100 || +x > 8000
    

    (actually you don’t have to explicitly convert x but it does not hurt either and makes it clearer which data types you are comparing)

    Update: And you have to replace && with || as far as I can see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry guys, I hate asking dumb questions but I have seriously been searching for
Ok, so I hate asking RegEx questions because I like to figure them out
Well, I do hate asking vague questions but I can't help it this time:
I hate to have to ask, but I'm pretty stuck here. I need to
I hate generating an exception for things that I can simply test with an
I hate asking memory management questions - all the good answers are variations on
I hate to ask but I had to. I have an html code. For
I hate asking questions like this - they're so undefined... and undefinable, but here
query = Files .Where(file => file.Fileinfo.Name.ToUpper().Contains(textBox1.Text.ToUpper())) .Take(7).ToList(); I hate asking this question, but I
I hate code that looks like its been hacked together. I have just written

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.