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.![]()

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.![]()
1) INT
2) Use javascript
EDIT:
Just did a quick google and got:
Usage: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 }}
REMEMBERCode:<input onkeypress=”return numbersonly(event);” name=”NAME”>![]()
Last edited by Florx; 15-12-2007 at 04:50 PM.
1) Thanks
2) I did![]()
![]()
But isn't there an option to do it in html?
No there isn't![]()
Well I google'd "JavaScript Numeric Only Input".
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.
No it cant? what you just did was completely different from what you asked people to do?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.";
}
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.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
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.
you could actually use php and js, but js would be easier on its own
Want to hide these adverts? Register an account for free!