This project has moved and is read-only. For the latest updates, please go here.

Autocomplete breaks when updating from 2014.01 to 2014.02

Mar 20, 2015 at 1:01 PM

Today I tried to update to 2014.02, but this immediately caused problems. For now I have reverted to the old version, but due to the possible performance improvements I would like to be able to use the most recent version.

The page I am currently testing on, uses the autocomplete function.
<script type="text/javascript" src="/Style%20Library/SPServices201402.js"></script>
<script language="javascript" type="text/javascript">
    $(document).ready(function() {
            sourceList: "{C09D3DF4-A601-476F-A265-90127B18D218}",
            sourceColumn: "Title",
            columnName: "Title",
            filterType: "Contains",
            CAMLQuery: '<Neq><FieldRef Name="Archief"/><Value Type="Boolean">1</Value></Neq>',
            ignoreCase: true,
            numChars: 2,
            slideDownSpeed: 250,
            debug: true,
            highlightClass: "bartBold",
Using FireBug I found the following error:
TypeError: findFormField(...) is undefined
Line 3281
(I am using the full version of 2014.02 for debugging purposes.)

I have switched versions several times and no errors occur when I change to 01.

Is the code I use no longer valid for 02 or did I miss anything? I've tried to look at other discussions but I could not find a solution.

Thank you in advance for any assistance!
Mar 20, 2015 at 2:21 PM
The findFormField function looks for the standard comment that precedes a form field in the HTML. It definitely works in 2014.02 because a number of functions use it.

What version of SharePoint are you on? Is the page where you are using it a default list form or have you made edits to it?

Mar 20, 2015 at 2:28 PM
Thank you for your quick reply.
I am on SharePoint 2013 (Foundation).

It is a custom page with a form added to it. It's a page showing the results from a filter (the filter is based on what the user fills in to the field with the autocomplete on it) on a document library.

Were there any changes from 01 to 02 in how this comment is detected?
Mar 20, 2015 at 3:43 PM
I don't think I made any change to that function, but there may be something I'm not catching. Can you post the markup for the column?

Mar 20, 2015 at 4:11 PM
I'm sorry but I am not sure what you mean exactly or how to get that information.
Mar 20, 2015 at 6:17 PM
I mean the HTML for the input element and the surrounding part of the page. findFormField looks for very specific things in that markup in order to find the element.

Jul 11, 2016 at 4:49 PM
Edited Jul 11, 2016 at 5:27 PM
The findFormField function looks for the standard comment that precedes a form field in the HTML.
Hey Marc

Can you go into this a little bit, I'm having a similar issue as OP on a custom form.

This is the row:
ASP in SPDesigner
<!-- E-Class Tracking Number -->
    <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
            <nobr>E-Class Tracking Number</nobr>
    <td width="400px" valign="top" class="ms-formbody" colspan="2">
        <SharePoint:FormField runat="server" id="ff29{$Pos}" ControlMode="New" FieldName="E_x002d_Class_x0020_Tracking_x00" __designer:bind="{ddwrt:DataBind('i',concat('ff29',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@E_x002d_Class_x0020_Tracking_x00')}"/>
        <SharePoint:FieldDescription runat="server" id="ff29description{$Pos}" FieldName="E_x002d_Class_x0020_Tracking_x00" ControlMode="New"/>

HTML - In Console:
  <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader"><nobr>E-Class Tracking Number</nobr></H3>
  <td width="400px" valign="top" class="ms-formbody" colspan="2">
    <span dir="none">
  <input name="ctl00$m$g_26e70b74_d268_40f2_bb71_9b4b5a359b36$ff291$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_m_g_26e70b74_d268_40f2_bb71_9b4b5a359b36_ff291_ctl00_ctl00_TextField" title="E-Class Tracking Number" class="ms-long ms-spellcheck-true" />
<br />
This is the findFormField(columnName) function:
 function findFormField(columnName) {
    var thisFormBody;
    // There's no easy way to find one of these columns; we'll look for the comment with the columnName
    var searchText = RegExp("FieldName=\"" + columnName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + "\"", "gi");
    // Loop through all of the ms-formbody table cells
    $(",").each(function() {
      // Check for the right comment
      if (searchText.test($(this).html())) {
        thisFormBody = $(this);
        // Found it, so we're done
        return false;
    return thisFormBody
  } // End of function findFormField
When you say it's looking for a comment, I don't understand if you mean like an HTML comment <!-- --> or something else.

In the findFormField function your RegExp is looking for something that begins with "FieldName" but that's an ASP property, not an HTML property so the rendered HTML input fields wouldn't have this property. Wouldn't this line searchText.test($(this).html()) always return false?

Thank you.
Jul 12, 2016 at 1:17 AM
The findFormField function is looking for a comment in the HTML that looks like this:
<!-- FieldName="Title"
If you look at any out of the box form, you'll see that kind of comment inside the HTML for the field control.
<td valign="top" width="350px" class="ms-formbody">
        <!-- FieldName="Title"
            <span dir="none"><input type="text" value="" maxlength="255" id="Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField" title="Title Required Field" style="ime-mode : " class="ms-long ms-spellcheck-true"><br></span>