Access to input type - cross-browser

J

johkar

I see some people accessing a forms' input type without converting
toLowerCase() and others do. Do some browser's return type as
uppercase?

This
document.forms['myFormName'].elements['myElementName'].type=='select-one';

or this
document.forms['myFormName'].elements['myElementName'].type.toLowerCase()=='select-one';

Somewhat related, what about when tag names and events...does case
matter?

Thanks
 
F

Fred Oz

johkar said:
I see some people accessing a forms' input type without converting
toLowerCase() and others do. Do some browser's return type as
uppercase?

This
document.forms['myFormName'].elements['myElementName'].type=='select-one';

or this
document.forms['myFormName'].elements['myElementName'].type.toLowerCase()=='select-one';

Somewhat related, what about when tag names and events...does case
matter?

DOM Level 3:

1.3.1 String Comparisons in the DOM

The DOM has many interfaces that imply string matching. For

XML, string comparisons are case-sensitive and performed with a

binary comparison of the 16-bit units of the DOMStrings .
However, for case-insensitive markup languages, such as HTML
4.01 or earlier, these comparisons are case-insensitive where
appropriate.

Note that HTML processors often perform specific case
normalizations (canonicalization) of the markup before the DOM

structures are built. This is typically using uppercase for
element names and lowercase for attribute names. For this
reason, applications should also compare element and attribute
names returned by the DOM implementation in a case-insensitive
manner.



<URL:http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Core-DOMObject>


I think the last sentence is very important to your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top