hyperPad hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    What's the best way to check if input is not a number

    Scheduled Pinned Locked Moved Help and Support
    18 Posts 5 Posters 4.0k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael KhalfinG Offline
      Michael Khalfin @Kamdroid
      last edited by

      @kamdroid Cool, I will check it out because it sounds interesting!

      1 Reply Last reply Reply Quote 0
      • Aidan_FireA Offline
        Aidan_Fire @iTap Development
        last edited by Aidan_Fire

        @itap-development 🙄
        0_1522847857495_F4C45EF1-DB27-4105-ACA7-A0BBEC30A71E.jpeg
        EDIT: this does not work, use the other one somewhere above.

        Jack de WildeJ 1 Reply Last reply Reply Quote 0
        • Jack de WildeJ Offline
          Jack de Wilde @Aidan_Fire
          last edited by

          @aidan-oxley those first 2 ifs should be checking if it's zero, right? Because text+1 is the same as 0+1?

          Aidan_FireA 1 Reply Last reply Reply Quote 0
          • Aidan_FireA Offline
            Aidan_Fire @Jack8680
            last edited by Aidan_Fire

            @jack8680 First it checks whether the value is the number 1 or not, if it is then it's done and it's a number. If it's not the number 1, then it adds 1 to it. If that result is 1, then it was text (since text will be treated as zero, so 0 + 1 = 1), if the result was not 1, then it is any number other than 1 (since 1 was already checked for at the start). I prefer adding 0 rather than 1 lol.

            1 Reply Last reply Reply Quote 0
            • iTap DevelopmentI Offline
              iTap Development @iTap Development
              last edited by

              @itap-development said in What's the best way to check if input is not a number:

              Just realized this won’t work if the input is already the number 0 though lol. You would still get the output of 1 (or 0).
              But another if would fix!

              🤦‍♂️ just realized your first screen shot already did this... I’m stupid🤯

              1 Reply Last reply Reply Quote 0
              • KamdroidK Offline
                Kamdroid
                last edited by

                I thought the first if statements should check if it is 0, not 1, too.

                If input was 0, 0+1 = 1, creating a false-positive to it being not a valid number.

                If input was 1, and the if statements didn't exist, 1+1 = 2, this would say it is a valid number.

                1 Reply Last reply Reply Quote 1
                • Aidan_FireA Offline
                  Aidan_Fire
                  last edited by

                  Ah ok, yeah the second one I made just to satisfy @iTap-Development's OCD wouldnt work, the first set of Ifs probably needed to stay as zero. Just use the one that adds zero lol.

                  iTap DevelopmentI 1 Reply Last reply Reply Quote 0
                  • iTap DevelopmentI Offline
                    iTap Development @Aidan_Fire
                    last edited by

                    @aidan-oxley 🤣

                    1 Reply Last reply Reply Quote 0
                    • iTap DevelopmentI Offline
                      iTap Development
                      last edited by

                      Whether you add 1 or 0 you still need all the ifs in both screen shots, right?

                      Aidan_FireA 1 Reply Last reply Reply Quote 0
                      • Aidan_FireA Offline
                        Aidan_Fire @iTap Development
                        last edited by

                        @itap-development Yeah.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post