View Full Version : is there a getdatatype function in javascript?
loadimmediate
11-07-2002, 08:16 PM
i need to retrieve a datatype - is there a javascript function that will do so? i need it make sure that inputs in a form are all of data type number or integer...
beetle
11-07-2002, 08:37 PM
You can use the typeof keyword, but this only works with JS variables. Any value you retreive from a form input will be typeof 'string', unless you enact parseInt() on that string value, but then you'd already know that it is typeof 'number', so reading it's type with typeof would be a moot point.
Are you trying to validate user input? Make sure they only enter numbers before submitting?
P.S. The javascript variable types I can think of off the top of my head...
number
string
boolean
array
object
loadimmediate
11-07-2002, 08:46 PM
OK I see your point, thanks for the reply. I am trying to validate user input on a form and yes, I need all form variables to be in numerical format.
Can you suggest a way to accomplish this?
Thanks again...
beetle
11-07-2002, 09:02 PM
Originally posted by loadimmediate
Can you suggest a way to accomplish this? Why I most certainly can! Click on the fValidate link in my signature! :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.