How to specify a range of fields input + js?

Hello. Prompt: you need to specify the range of input numbers in input from 10 to 100. If the number is larger or smaller, you should instead enter in the number respectively substituting the maximum or minimum. How to do it in js?
June 14th 19 at 19:13
2 answers
June 14th 19 at 19:15
Solution
I have here what happened: https://codepen.io/palehin/pen/yzvGWX
The solution is not perfect.
Without jQuery.
June 14th 19 at 19:17
var elem = document.getElementById('myInput');
elem.onchange=function(e){
 var value = parseInt(e.target.value);
 if(!value || value <=10 || value > 100) {
 /*To do something.
 Clear the field.
*/
 e.target.value = ";
}
}
Yes, this example works only wish that was substituted is not the empty string, and sootvetstvenno znacheniye maximum or minimum. - Althea39 commented on June 14th 19 at 19:20
well so see if the value entered is less than acceptable, minimalnoe, if more then the maximum. - britney38 commented on June 14th 19 at 19:23
understood , thank you) - Althea39 commented on June 14th 19 at 19:26

Find more questions by tags JavaScript