HTML Input Restrict Numbers?

Ratchetr

New member
You can't in HTML alone. You would have to use JavaScript.

Yeah, you can use the drop down list approach. I really REALLY hate it when developers go that route. I know WHY they do it, but it really makes for a crappy user interface.

The one that really irks me is State. I can type NY in about 3 nanoseconds. To pick NY from a dropdown takes 5+ seconds (even if you use the keyboard, because you have to type N 4 times to get to NY).

Learn some javascript and validate that way.
 
is there anyway I can use the HTML input tag and restrict the text to be only a value from 1-10.

I know I can make it only numbers and restrict it to only 2 characters, but that leaves me open to 99. Is there anyway I can do this with only HTML?
 
If you mean only integers between one and ten, don't use a textbox at all. Use a <SELECT> box and give it <OPTION>1
<OPTION>2
.
.
.
<OPTION>10
</SELECT>

That way, you can control exactly what values the user can pick.

Additional Details: Clearly, Ratcheter and I have different opinions on the matter. Most browsers, of course, still allow you to type into select boxes, as long as what you type matches something IN the box. He can still type "NY". He doesn't have to hit "N" four times. Your user can still type "5".
 
You can't in HTML alone. You would have to use JavaScript.

Yeah, you can use the drop down list approach. I really REALLY hate it when developers go that route. I know WHY they do it, but it really makes for a crappy user interface.

The one that really irks me is State. I can type NY in about 3 nanoseconds. To pick NY from a dropdown takes 5+ seconds (even if you use the keyboard, because you have to type N 4 times to get to NY).

Learn some javascript and validate that way.
 
You can't in HTML alone. You would have to use JavaScript.

Yeah, you can use the drop down list approach. I really REALLY hate it when developers go that route. I know WHY they do it, but it really makes for a crappy user interface.

The one that really irks me is State. I can type NY in about 3 nanoseconds. To pick NY from a dropdown takes 5+ seconds (even if you use the keyboard, because you have to type N 4 times to get to NY).

Learn some javascript and validate that way.
 
Back
Top