Reputation: 10541
How can I detect the data type, load the data type into a variable, and then run appropriate 'if' statements based on the data type?
This seems to think everything's a string:
$("#input1").change(function(){
var keyboard_input = $(this).val();
alert("That was a " + jQuery.type(keyboard_input));
});
Upvotes: 0
Views: 72
Reputation: 18861
Everything the user enters into the input field is a string - a sequence of characters entered from keyboard.
If you want to get eg. integers and booleans, you will have to parse this string.
To get a boolean, you can check if the string equals to 'true'
or 'false'
.
To get numeric values, you will have to use some regular expression.
Here's an example JsFIDDLE to give you a starting point.
Upvotes: 5