How can I check if x is an integer in javascript?
- 1 -> OK
- 11 -> OK
- 1.1 -> not OK (decimal place)
- null -> not OK (null)
- a -> not OK (letter)
- 1e1 -> not OK (letter)
1 1 -> not OK (sapce in any position (include front or end))
var x = document.forms["myForm"]["numofquestions"].value; if (x==null || x=="" || isNaN(x) || x<1 || x>500 || (x%1 != 0)) { alert("Please fill in number between 1 - 1000"); }