OK, this probably sounds real basic, and should anyone have the solution, become apparent on how basic it is, but damn my minds blank.
What i need is, to be able to limit a text field to 8 characters, and only allow it to be numerical. as the input field is for posting a member ID
limiting input fields
Started by tones, Mar 10 2008 05:57 AM
4 replies to this topic
#1
Posted 10 March 2008 - 05:57 AM
#2
Posted 10 March 2008 - 07:13 PM
<input type="text" name="test" value="123456789" maxlength="8">
Or to be 100% about it's length:
strlen() (of course, substr() could "cut out" additional characters).
Then for the number part: is_numeric()
#3
Posted 11 March 2008 - 05:55 AM
Thanks i got it, i used eregi to check it was numerical and strlen for the length.
Edited by tones, 11 March 2008 - 05:56 AM.
#4
Posted 14 March 2008 - 10:04 PM
learn how to use substr() and that will be your new best friend!
Edited by SpatialVisionary, 14 March 2008 - 10:05 PM.
#5
Posted 15 March 2008 - 12:41 AM
Well, when taking a member id, the idea is not to truncate any erroneous characters. It is to make sure it fits certain parameters, or alert the user to their having provided incorrect information.
Though, i still recommend is_numeric() over eregi (numbers really only have one case, and are usually only numbers...).
Though, i still recommend is_numeric() over eregi (numbers really only have one case, and are usually only numbers...).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
