javascript - Validate input field, display error on submit and stop dialog open if error -
i have problem trying validate input field , alert error, if number below 50, know how display error popup (alert, or ever), stop opening dialog modal if error occurred.
i did script force users write numbers below 50 with:
<script> function handlechange(input) { if (input.value < 50) input.value = 50; if (input.value > 1000000) input.value = 1000000; } </script>
but once user type, example: 23 , click on submit, it'll change number in background 50, not aware of that... can it?
here's full code i'm using:
<form id="testconfirmjq" name="testconfirmjq" method="post" onsubmit="return validator(users)" action="output.php"> <label> <select id="selectusers" class=" outtahere" name="users" onchange='choice();'> <option value="0" selected="selected">choose...</option> <option value="1">test</option> </select> </label> <input type="hidden" id="ids" name="ids" > <input type="hidden" id="use" name="username" > <input type="hidden" id="ful" name="full_name" > <p> how much? <input type="text" id="quantity" name="quantity" onchange="handlechange(this);"> <div style="font-size: 12px; float: left;">*minimum quantity: 50</div> </p> <input id="submitjq" name="submitjq" type="submit" class="styled-button-1" value="send" /> </form> <div id="dialog" title="potvrdite"> <div class="scroll-content"> <ul class="countrylist"> <img src="./images/png.png" class="vizitke"/> </ul> </div> </div>
thanks in advance...
<script> function handlechange(input) { if (input.value < 50) { alert('your alert'); input.value = 50; } if (input.value > 1000000) { alert('your alert'); input.value = 1000000; } return false; } </script>
i looking for
Comments
Post a Comment