Using buttons on a numeric keypad to send back a value to the controller but the keypad wont let me go below 0 when I press the '-' button, the user may need to pass back a negative value.
Also if possible, if the user has -32 for example and they pres '-' twice it will change to +32. Can anyone give me a hand with this? not use to working with script? ta
Alot of 0's so unsure which one to change?? thanks
<script>
$(document).ready(function () {
$('.numero').click(function () {
if (!isNaN($('#myInput').val())) {
if (parseInt($('#myInput').val()) == 0) {
$('#myInput').val($(this).text());
} else {
$('#myInput').val($('#myInput').val() + $(this).text());
}
}
});
$('.neg').click(function () {
if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
if (parseInt($('#myInput').val()) > 0) {
$('#myInput').val(parseInt($('#myInput').val()) - 1);
}
}
});
$('.pos').click(function () {
if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
$('#myInput').val(parseInt($('#myInput').val()) + 1);
}
});
$('.del').click(function () {
$('#myInput').val($('#myInput').val().substring(0, $('#myInput').val().length - 1));
});
$('.clear').click(function () {
$('#myInput').val('');
});
$('.zero').click(function () {
if (!isNaN($('#myInput').val())) {
if (parseInt($('#myInput').val()) != 0) {
$('#myInput').val($('#myInput').val() + $(this).text());
}
}
});
});
</script>