If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Reality Check range 0-99 problem

Hi guys,
I have a program that works fine, but I would like to add another check to the code. I want the user to only be able to enter numbers from 0-99. Can anyone suggest how I would do that. Any help is greatly appreciated.
Thanks

If you have a field that is numeric, then you can simply -0 from the string value to return a numeric value, eg.

[CODE]var twix = document.getElementById("twix").value-0;[?CODE]

in the HTML side of things, you can limit the number of character that the field will accept to 2 characters. You could attach a script to run on change to check that any character input is a number 0-99 as well.

All the code you need is on developer.com and only needs searching for.

--> JavaScript Frameworks like JQuery, Angular, Node <--
... and please remember to wrap code with forum BBCode tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...