-3
<input type="number" name="quantity" min="0" max="100" #weightCQ="ngModel"   style="width:80px" placeholder="Weightage" [(ngModel)]="weightage[j]">

Here the input should not take a value more than 100

Bijender Singh Shekhawat
  • 3,934
  • 2
  • 30
  • 36
  • what is not working? – Abhishek Pandey Feb 21 '19 at 06:21
  • ngModel? Maybe this answer could help: https://stackoverflow.com/questions/45480004/min-and-max-value-of-input-in-angular4-application – Lucien Dubois Feb 21 '19 at 06:23
  • @AbhishekPandey Please correct your question. – Raahul Feb 21 '19 at 06:25
  • it will take the values but when you will try to submit the form it will show the error – Adesh Kumar Feb 21 '19 at 06:25
  • @Raahul I guess my question is correct, SO has tons of question and answers on this topic, OP should have search it first instead of posting this question. – Abhishek Pandey Feb 21 '19 at 06:28
  • Possible duplicate of [How can I limit possible inputs in a HTML5 "number" element?](https://stackoverflow.com/questions/8354975/how-can-i-limit-possible-inputs-in-a-html5-number-element) – Abhishek Pandey Feb 21 '19 at 06:28
  • It is not inside a form , just an input field in an diaglog box which is not having form , user should not be able to add number more than 100 manually which is not happening – Aditya Lamba Feb 21 '19 at 07:05
  • @AdityaLamba You can try this in jquery -> `$('#yournumberboxid').keyup(function(){ if ($(this).val() > 100){ alert("plzz enter number less then 100"); } });` – Swati Feb 21 '19 at 07:08

1 Answers1

-1

You can do this with jquery

$('#100').keyup(function(){
 if($('#100').val() > 100) {
 $('#100').val(100);
 }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="quantity" id="100" min="0" max="100" #weightCQ="ngModel"   style="width:80px" placeholder="Weightage" [(ngModel)]="weightage[j]">
Sukhjinder Singh
  • 479
  • 3
  • 15