I want to avoid negative values and decimal values in form input, like 1.25, 4.5 etc using javascript validation.
For negative numbers I am using type="number" and min="0" in input. But how to handle decimal values?
Any help would be great
I want to avoid negative values and decimal values in form input, like 1.25, 4.5 etc using javascript validation.
For negative numbers I am using type="number" and min="0" in input. But how to handle decimal values?
Any help would be great
The HTML5 support for the in-form validation might not be available across all browsers.
if(number !== parseInt(number,10)){
//detects floating point numbers like 1.3
} else if (number > -1) {
// detects negative numbers
}