How do I use Javascript to force the cursor on a specific form field when the form field has a name with parentheses?


I am using CakePHP as my framework.

On page load, I want to force the cursor to a specific form field where name="data[Project][title]"

I'm trying to use javascript:

This works fine if I change the name to something without brackets, but fails to work with this form name. I have to use this form field name because of how CakePHP processes my form data.

Is there a workaround or another simple way to force the cursor to this form field?

Here is the code I currently have (if you change "data[Project][title]" to "formField" it works):

<body onLoad="[Project][title].focus();">

<form action="" method="post" id="create-form" name="searchForm">

<input id="main-input" type="text" class="title-limit" name="data[Project][title]" onClick="this.value='';limitText(60);" onKeyDown="limitText(60);return true;" onKeyUp="limitText(60);return true;" />

Example code? Because otherwise you could simply do: