Skip to content

Instantly share code, notes, and snippets.

@imsickofmaps
Last active August 29, 2015 14:00
Show Gist options
  • Save imsickofmaps/11176199 to your computer and use it in GitHub Desktop.
Save imsickofmaps/11176199 to your computer and use it in GitHub Desktop.
self.check_valid_number = function(input){
// an attempt to solve the insanity of JavaScript numbers
var numbers_only = new RegExp('^\\d+$');
if (input !== '' && numbers_only.test(input) && !Number.isNaN(Number(input))){
return true;
} else {
return false;
}
};
self.check_number_in_range = function(input, start, end){
return self.check_valid_number(input) && (parseInt(input) >= start) && (parseInt(input) <= end);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment