function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
zabahzabah 

Illegal Form Object Names

Hey:

We've created some custom fields for our contacts and accounts and Salesforce gave these fields unique ID (e.g. 00N30000000d8Uu).  Unfortunately, because this ID starts with a number, I'm unable to perform simple Javascript functions on the values of the form objects that result from these fields as Javascript considers illegal any form object whose name begins with a digit.

Has anyone gotten around this?  Is there a way to request an ID that begins with a character of the alphabet?

Zabah!

DevAngelDevAngel

Hi Zabah,

What if you prepend the fieldnames with an underscore or some other non-digit character?  You could then get the object id by removing the prepended char when processing the form submission.

zabahzabah

The answer is so simple, I'm embarrassed.

To get the value of a custom field in javascript, use the array of the form object:

strVariable = document.frmForm['00N30000000dIPr'].value;

I know it works in IE.  Pretty sure it works in Netscape.  I have not tested it in other browsers, though.