0

I'm migrating a SharePoint 2010 VS project to SharePoint 2013. The project has custom list definitions and custom add, edit and view forms and uses jQuery 1.8.3. In 2010 the following code works fine:

if ($("#" + $("input[title='Title']").attr('ID')).val().trim() == "") {
     bvalSubmit = false;
}

I'm validating an input field within the form and making sure that it has a value before I enable the submit button.

In SharePoint 2013 I get the following error:

Syntax error, unrecognized expression: #Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField

jquery-1.8.3.js

Line: 4680

I've taken a look in Firebug at the difference between the 2010 and 2013 HTML and this is what I've found:

2010

<input id="ctl00_m_g_4d4c596f_8236_477a_b1de_e5a4f2f4034e_ctl00_AddForm1_ff4_ctl00_ctl00_TextField" class="ms-long ms-spellcheck-true" type="text" title="Title Required Field" maxlength="255" name="ctl00$m$g_4d4c596f_8236_477a_b1de_e5a4f2f4034e$ctl00$AddForm1$ff4$ctl00$ctl00$TextField">

2013

<input id="Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField" class="ms-long ms-spellcheck-true" type="text" style="ime-mode : " title="Title" maxlength="255" value="">

When I step through jQuery it fails within the Sizzle function. I've search everywhere for a solution to this without success. Any help would be appreciated.

1 Answer 1

1

Try using below code

if($("input[Id^='Title']").val().trim() == "") {
    bvalSubmit = false;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.