PDA

View Full Version : It is possible to check the existence of input text objetcs ?


loliveira
03-12-2003, 01:02 PM
I need to know if there is any input objects to work with in a form, or if the page contains only text.
Let me give an example:
In some cases I will have an editable element in a form (like an input text), but in some not.
If I reference an object that does´t exist in the page, i will have an error.
So, there is a way to treat this error, or a property that I can check to see if the object was correctly acessed (in other words, it exists in the form) ?
tkns !

brothercake
03-12-2003, 01:40 PM
if(typeof document.forms["formname"]["elementname"] != "undefined") { ... form element exists ... }


You can use typeof against "undefined" to test for the existence of any object - although there are a couple of oddities - for example, a non-existent image in Konqueror is null rather than "undefined"

Oh - and welcome to the Forums :)