I am trying to check if some option has been selected from a drop-down list in javascript. When the user selects an item in the drop-down list, the below change event function, is triggered. The value is a string that either contains an empty string "" or a numeric value such as "0", "1", "2", "3", etc.
function (event, value) {
if (value >=0)
{
// Do some stuff here
}
});
If an item has been selected from the drop down list (value >=0 but not empty) I want to execute some code. In above snippet code, the conditional body is always executed regardless of whether the value is empty or not. It does not work.
Which is the best way to check if coming value is a number (not empty string) and if so then check if that value is greater than 0?
Expected results are:
value == "" -> Conditional body should not be executed
value != "" and value >= 0 -> Conditional body should be executed.