Click to See Complete Forum and Search --> : <input type=range min=1 max=10...not working


jwbond
11-19-2004, 12:35 PM
I am trying to make it so the user can only input a number between 5,000 and 100,000 using the following

<input type=range min=5000 max=100000 value="0.00" size=20 maxlength=50>

but if i put in a value of 1 then it still lets me proceed, help!

Jona
11-19-2004, 12:38 PM
Read the sepcs (http://www.w3.org/TR/html401/) - there is no "range" input type (http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT). You can control the value of an input using JavaScript, but any JavaScript validation can be hacked through; instead, do all necessary validation server-side, and if you feel it necessary, do client-side validation via JavaScript.

russell
11-19-2004, 05:12 PM
Jona
and if you feel it necessary, do client-side validation via JavaScript.

It is almost always a good idea to do client side form validation. I cannot think of one www form that gets submitted to the server where the user can type in data that one wouldn't want to do it.

It is much more user friendly to let them fix typos or warn them that required fields are missing before they submit than after. It also saves resources on your servers, and to some extendt saves wasted bandwidth on the users network/internet.

Client-side validation is not a replacement for server-side validation, and you end up writing essentially the same code twice, but for the reasons above, it is a good idea. Just make sure that your form doesn't depend on client-side code, and don't be lazy about the server-side validation just because the client-side code works (we can easily disable JavaScript).

Jona
11-19-2004, 06:05 PM
Originally posted by russell
It is almost always a good idea to do client side form validation. I cannot think of one www form that gets submitted to the server where the user can type in data that one wouldn't want to do it.

It is much more user friendly to let them fix typos or warn them that required fields are missing before they submit than after. It also saves resources on your servers, and to some extendt saves wasted bandwidth on the users network/internet.

Client-side validation is not a replacement for server-side validation, and you end up writing essentially the same code twice, but for the reasons above, it is a good idea. Just make sure that your form doesn't depend on client-side code, and don't be lazy about the server-side validation just because the client-side code works (we can easily disable JavaScript).

Thanks for the elaborating for me. ;)

patenaudemat
07-24-2007, 03:19 PM
OK, I know this is a really old post, but I ran across it while doing some research, and wanted to make a quick point:

There "is" an input type called range. However, it is not a part of the current W3C recommendation-- rather, it is part of WHATWG's Web Forms 2.0 (http://www.whatwg.org/specs/web-forms/current-work/#extensions).

Just trying to explain where that guy's code probably came from. ;)

-Matt