简体   繁体   中英

How to replace the value of an input if it is less than a minimum value established?

How do I make this calculation in javascript, and how do I do it so that the final result has a minimum value of 3500?

 <div id="multiplicar-fijos"> <div> <input type="text" id="multiplicando-fijos" value="" onChange="multiplicar();" /> <input type="text" id="multiplicador-fijos" class="" value="75" onChange="multiplicar();" readonly="readonly" /> <input type="text" id="resultado_1" class="monto" onkeyup="sumar();" readonly="readonly" /><span id="Costo"></span> </div> <div> <input type="text" id="multiplicando-itinerantes" value="" onChange="multiplicar2();" /> <input type="text" id="multiplicador-itinerantes" class="" value="275" onChange="multiplicar2();" readonly="readonly" /> <input type="text" id="resultado_2" class="monto" onkeyup="sumar();" readonly="readonly" /> </div> <div> <span>El resultado es: </span> <input type="text" id="Total" onchange="cambio(this)" /> </div> </div>

您可以简单地使用Math.max的值和所需的最小值。

Math.max(value, 3500)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM