I have a form with an input text field and I want to validate it before I submit the form.
You can enter a natural number like 1, 5, 7
etc or you can enter a float number like 1.5, 5.45, 7.38
How can I detect when the input has an Integer (natural) number or not?
If I'm using:
typeof($(input[name='myField']).val())
I always get it as a string.
I tried to convert the string to a number, but using parseInt
or parseFloat
doesn't help, as I convert it directly from the code.
I need to know what type of number is the one in the string from the input field.