Skip to content

Instantly share code, notes, and snippets.

@arsho
Created October 26, 2016 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arsho/9380b4b8bcd278020b08a7e9d083dbdd to your computer and use it in GitHub Desktop.
Save arsho/9380b4b8bcd278020b08a7e9d083dbdd to your computer and use it in GitHub Desktop.
validation of integer number
// 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