Yes. First, either grab the specific input element or all the elements.
/* For a specific element. Search by its id property.
var input=document.getElementById("element_id"); OR
// For an array of all elements in your document.
var inputs=document.getElementsByTagName("input");
For the first example, you can see its type by:
alert(input.type);
if (input.type=="textbox") ....
For the second example, you can see its type by:
alert(inputs[0].type);
Of course, you pick whichever index you need or simply loop through them all.
Lastly, a select box is not an input. It is a select tag.
True, select is not an input, but it still has a type property. Which brings up a good point: the reference I gave above only shows the types for input tags, but there are other tags that have types too. The MSDN DHTML Reference has type property entries for each of the following:
A, LINK, OBJECT
BUTTON
event
INPUT
LI, OL, UL
PARAM
SCRIPT
SELECT
selection
STYLE
styleSheet
TEXTAREA
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.