var val= $('#num').val(); // 01
if(isNaN(val) || val > 59 || val== ''){
alert("error");
}
In this case, has not alert error
var val= $('#num').val(); // 01
val = parseInt(val);
var val= $('#num').val(); // 01
if(isNaN(val) || val > 59 || val== ''){
alert("error");
}
In this case, has not alert error
var val= $('#num').val(); // 01
val = parseInt(val);
Well you code has no val in it, guessing it is a typo.
isNaN(val) <-- checking to see if a string is a number?
val > 59 <-- comparing string vs a number. NOT a number vs Number
val== '' <-- seeing if a string is matching nothing
You want to use parseInt() for the second check. Read the linked page.
You need to:
Define a variable name: var yourVariable = "01";
Then use typeof to find its type: typeof(yourVariable);
typeof will return "string", in my example. It can also return "number" or "undefined" - very useful.