Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default Two simple questions!

    Hey, two really quick simple questions!

    1) For SQL, what type to you put it as so only numbers can be in it not text?
    2) What do you put so on an HTML form the input can only be numbers?

    Two simple questions, I don't know my head kills.

  2. #2
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    1) INT
    2) Use javascript

    EDIT:

    Just did a quick google and got:
    Code:
    function numbersonly(e) {
    var unicode=e.charCode? e.charCode : e.keyCode;
    if (unicode!=8){ //if the key isn’t the backspace key (which we should allow) 
    if (unicode<48||unicode>57) //if not a number return false 
    
    //disable key press 
    }}
    Usage:
    Code:
    <input onkeypress=”return numbersonly(event);” name=”NAME”>
    REMEMBER
    Last edited by Florx; 15-12-2007 at 04:50 PM.

  3. #3
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    1) Thanks
    2) I did

    But isn't there an option to do it in html?

  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    No there isn't

  5. #5
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Well I google'd "JavaScript Numeric Only Input".

  6. #6
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    I was thinking, I should know if there is...

    I don't want to use javascript in it, ah, I'll just make sure whoever inputs anything in it makes sure it's a number.

    (It's not going to effect any security, it's just the value of the credit code )

    Edit: Ah good, it can be done with PHP.

    PHP Code:
        if (!is_numeric($_POST['amount'])) {
            echo 
    "The amount you entered wasn't a number.";
            } 
    Last edited by Hitman; 15-12-2007 at 05:03 PM.

  7. #7
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Hitman View Post
    I was thinking, I should know if there is...

    I don't want to use javascript in it, ah, I'll just make sure whoever inputs anything in it makes sure it's a number.

    (It's not going to effect any security, it's just the value of the credit code )

    Edit: Ah good, it can be done with PHP.

    PHP Code:
        if (!is_numeric($_POST['amount'])) {
            echo 
    "The amount you entered wasn't a number.";
            } 
    No it cant? what you just did was completely different from what you asked people to do?
    You asked if it were possible to stop anyone entering none numeric text in to a text box... there was using Js.
    What you just did is check whether an input is numeric. This has no effect on whether text can be entered in to the textbox o.0

  8. #8
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by 01101101entor View Post
    No it cant? what you just did was completely different from what you asked people to do?
    You asked if it were possible to stop anyone entering none numeric text in to a text box... there was using Js.
    What you just did is check whether an input is numeric. This has no effect on whether text can be entered in to the textbox o.0
    Yes, you're right, sorry.

    What I posted will check if it's a number, if it's not it echos that it wasn't a number and wont input into the DB.

    I wanted so only numbers can be inputted, but if I had been given this aswell I wouldn't have minded, so yes I worded it wrong as well in a way.

    The matter is closed now, (the thread can be left open) because I have something similar to what I intentionally needed.

  9. #9
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    you could actually use php and js, but js would be easier on its own

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •