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 3606012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:11:43+00:00 2026-05-18T21:11:43+00:00

I am having a set of text fields where i am doing validation Say

  • 0

I am having a set of text fields where i am doing validation
Say I am Having a field called “seats” this can accept
value less than “99999”.Meaning I should not able to enter the
“99999” any thing less than that is ok. For that I wrote below if and else if .
please tell me whether I am doing any thing wrong. I am confused a lot from morning
whether it should be less than or greater than

if ($("#seats").val() != '') {
    setflag = false;
    alert("Not a valid character")
}
else if($("#seats").val() < 99999) {
    alert("Not a valid Number");
} else {
    setflag = true;
}
  • 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-18T21:11:44+00:00Added an answer on May 18, 2026 at 9:11 pm

    Iam confused a lot from morning whether it should be less than or greater than`

    this can accept value less than "99999"

    I think you answered it yourself… But it’s valid when it’s less than. Thus the following is incorrect:

    }elseif($("#seats").val() < 99999){
      alert("Not a valid Number");
    }else{
    

    You are saying if it’s less than 99999, then it’s not valid. You want to do the opposite:

    }elseif($("#seats").val() >= 99999){
      alert("Not a valid Number");
    }else{
    

    Also, since you have $("#seats") twice, jQuery has to search the DOM twice. You should really be storing the value, or at least the DOM element in a variable. And some more of your code doesn’t make much sense, so I’m going to make some assumptions and put it all together:

    var seats = $("#seats").val();
    
    var error = null;
    
    if (seats == "") {
        error = "Number is required";
    } else {
        var seatsNum = parseInt(seats);
        
        if (isNaN(seatsNum)) {
            error = "Not a valid number";
        } else if (seatsNum >= 99999) {
            error = "Number must be less than 99999";
        }
    }
    
    if (error != null) {
        alert(error);
    } else {
        alert("Valid number");
    }
    
    // If you really need setflag:
    var setflag = error != null;
    

    Here’s a working sample: http://jsfiddle.net/LUY8q/

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

Sidebar

Related Questions

I'm having trouble trying to set the value of a property after i cast
I am trying to set the default value for a form field in SharePoint
I have a number of files that I checked into SVN without having set
With the new approach of having the get/set within the attribut of the class
I'm having some doubts on how to set up my SVN stuff. First my
I'm having trouble figuring out how to get the testing framework set up and
Having the hours and minutes, is there any easier or better way to set
i'm trying to set up the selenium-maven-plugin and having some difficulties i hope somebody
I've been having tons of problems getting the non-xml configuration for Castle Windsor set
I'm having some minor problems with some animations I'm trying to set up. I

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.