bosscat
asked on
Javascript : Enter Maximum value, minimum value and certain variables in textbox
hey all,
Below are the javascript to check on the textbox value. The textbox only allow user to enter 0 and the maximum value 100 but I also need to allow the user to enter '-' and 'X'. How do I modify the code to suits the criteria?
Thanks.
Below are the javascript to check on the textbox value. The textbox only allow user to enter 0 and the maximum value 100 but I also need to allow the user to enter '-' and 'X'. How do I modify the code to suits the criteria?
<input type="text" class="text-input small-input" maxlength="3" size="1" name="tov[]" value="0" onkeyup="this.value = minmax(this.value, 0, 100)"/>
<script type="text/javascript">
function minmax(value, min, max)
{
if(parseInt(value) < 0 || isNaN(value))
return 0;
else if(parseInt(value) > 100)
return 100;
else return value;
}
</script>
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks!! it works perfectly!
Open in new window