Limit input box
- Started
- Last post
- 28 Responses
- Raybandana
Hi There,
I can't figure out how limit a text box to a certain number.
So if I have an input box that can only input 6 and above... how do I do this?
Thanks very much.
- Raybandana0
Thats for max characters... i'm looking for max numbers... so if the min is 6... they cant type 5,4,3,2,1... but anything above 6.
- spot130
I'm not 100% clear on what you're trying to do but it sounds like you can either search for specific characters (numbers) in a string (contents of your input) or you can right an 'if equal or less than 5' statement to remove the characters you don't want.
It would be easier to understand if you could provide a usage scenario.
- spot130
String.contains:
http://stackoverflow.com/questio…if integer is greater / less than:
http://stackoverflow.com/questio…RegEx to check for specific characters and number of characters in string:
http://stackoverflow.com/questio…
- Raybandana0
Basically I have an input box. I need a number restriction on that box.
So the restriction is 5 or anything less than than 5. But allow the user to type 6 or anything greater then 6.
Is this possible?
How is this done?
- fadein110
do a select box with 1-5 - simples... are you joking?
- Raybandana0
Hey Im not super star developer - im just a designer learning to code...
How do I do this select box you speak of?
- Raybandana0
I just need an input box that only let you type in 6 or anything greater than.
- Raybandana0
a drop down list with options?
I need a restricted input box. Because I have the form set up a certain way - I cant introduce this kind of style... i would much prefer a restricted input box
- fadein110
If you are trying to be clever or need a really funky solution then look into javascript. If not just have a standard html select box with options 1-5. see link above - just add that with each option 1-5 as part of a form tag, make it look nice with CSS. if i have misunderstood your requirements then apologies.
- Raybandana0
Ahh I understand - thanks for the help - but im trying to be the cool guy... this is what I'm working on.. delicakitchen.ca/paulettes/onlin...
I just want to restrict the input boxes..
- BabySnakes0
Added an if statement to the refreshCustomBoxes(), that should force a 6 if user inputs an number less thatn 6 but keeps it at 0 if it is already 0. The each loop for the input boxes isn't set up the way i'd like but it should work.
- BabySnakes0
updated to set the input val to 6 as well...
- fadein110
your site needs to rely less on the back button - frustrating.
- Weyland0
pseudo code: onSubmit if(text.length()<6) return else submit
- Nathan_Adams0
Why not use a number input type?
Like a text box, only accepts numbers, and you can set min, max and step values.http://www.w3schools.com/html/tr…
That said, I can't understand what the problem is with fadein11's suggestion of a select box.
- he wants 6 and above to infinite, thats a big dropdown.mantrakid
- Raybandana0
thanks guys for the help!
- Raybandana0
Hey BabySnakes,
I added your If statements - but they dont seem to work.
Possibly because I don't know what I'm doing!Any help would be great.
Thanks.