Limit the number in the input box

0

I wanted to know how I limit the maximum number before and after the point.

Type, that are 3 numbers before the point and 2 after. How do I do this?

Code:

<script> 
function soma() 
{
form.campo4.value = parseInt(form.campo1.value*1) * parseInt(form.campo2.value*1) 
}
</script>
<script type="text/javascript">
$(function(){
 $("#demo4").maskMoney({symbol:'R$ ', 
showSymbol:true, thousands:'', decimal:'.', symbolStay: false});
 })

 $(function() {
   $(document).on('click', 'input[value][id=demo4]', function() {
     this.select();
   });

 });
 $("#demo4").bind('input propertychange', function(){
    if($(this).val() > 4){
         $(this).val() = 4;
    }else if($(this).val() < 1){
         $(this).val() = 1;
    }
});
</script>
    
asked by anonymous 03.09.2017 / 03:10

1 answer

1

Boot maxlength="9" in the input you want to do this.

With this, the field will not receive more than 5 characters entered (already with the decimal point and the symbol "R $").

Example: R $ 200.00

    
03.09.2017 / 03:19