javascript - Jquery input text allow decimal and value between 0.00 and 100 -
jquery input text allow decimal , value between 0.00 , 100
html :
<input name="score type="number" min="0.01" max="100" step="0.01">
is showing invalid when enter "1111" want validation after click submit button
<input type="text" name="score"> <input type="submit">
script:
if($(this).val()<= 0.01 && ($(this).val() <=100)){ // allow 0.01 100 100 return true; }
i want allow decimal in field
you can use html this:
<input type="number" min="0" max="100" step="0.01">
if don't want use html:
$(document).on("ready", function() { $("#form").submit(function(e) { var scoreval = $("#score").val(); if(parseint(scoreval) <= 0 || parseint(scoreval) > 100) { e.preventdefault(); console.log("wrong value entered!"); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form id="form"> <input id="score" type="text" name="score"> <input type="submit"> </form>
Comments
Post a Comment