Testing for the existence of a field in JS

by "Rajnish Bhaskar" <r.bhaskar(at)compserv.gla.ac.uk>

 Date:  Tue, 7 May 2002 10:35:25 +0100
 To:  hwg-basics(at)hwg.org
  todo: View Thread, Original
Hi folks,
I'm trying to write a simple JS validator and I can't seem to find
any way to test if a particular object exists.  Eg:

// where form.courseCode is a set of radio buttons that may or may
// not exist on the form
var testDates= form.courseCode;
if (testDates actually exists)
{ ... perform the validation ...}

I've tried if (testDates != null), if (testDates) and if
(testDates.length), none of which work.  Any ideas?

TIA,
Raj.
PS: please reply directly since I'm on the digest
-- 
Rajnish Bhaskar
r.bhaskar(at)compserv.gla.ac.uk, http://lordofthemoon.com
IT Education Unit, University of Glasgow
http://www.iteu.gla.ac.uk/
--
Only buffoons refer to the Internet as the Information Superhighway.
      -- (The Rough Guide to the Internet 1999)

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.