Created
October 26, 2016 11:30
-
-
Save arsho/9380b4b8bcd278020b08a7e9d083dbdd to your computer and use it in GitHub Desktop.
validation of integer number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// validation for ranging number | |
$('.subject_mark').on("keyup", function () { | |
this.value = this.value.replace(/[^0-9]/g, ''); | |
var input_value = parseFloat(this.value); | |
if (isNaN(input_value)===true) { | |
$(this).val("0"); | |
} else { | |
var max_value = parseFloat($(this).attr('max')); | |
if (input_value > max_value) { | |
$(this).val(max_value); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment