[SalesForce] changes ID and Name

I have a simple form where I need the input box to have the name and id in it.

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputText.htm

As the docs says, this:

<apex:inputText value="{!inputValue}" id="theTextInput"/> 

should output as

<input id="theTextInput" type="text" name="theTextInput" />

but it doesn't, it outputs as:

<input id="j_id0:main-form:theTextInput" type="text" name="j_id0:main-form:theTextInput" />

The form is wrapped in:

<apex:form id="main-form" styleClass="form-horizontal">

Is it possible to prevent that from happening?

Best Answer

You should have added this recent update as an edit or comment to your question, not as an answer ;)

The gibberish is there to make sure elements are unique. Id field - because Ids should be unique, duh. Name - to make sure submitted form is deserialized properly (if you'd have a table with several items & mass edit capability you'd want to make sure that 7th element's Name field is mapped correctly).

Easiest way around it is to use your own input field instead of <apex:...> tag. If that's not an option - you could reference it with jQuery as $("page\\:block\\:form\\:theInput") (fully specified path + escaping).

Or use the ends-with selector: $("input[id$='theInput']")