I'm trying to hide field C when field A equals B on the NewForm page. I used the JSLink attribute to add my scripts to the NewForm page.

 <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" JSLink="../Scripts/HideEndDateDuration.js|../Scripts/jquery-1.9.1.js"/>

I get a warning that the JSLink attribute is not declared.

I ignore that and try to test if it works. Here is my jquery to hide the field :


//Show/hide columns based on Drop Down Selection 
$("select[title='StartDate']").change(function() {
    if ($("select[title='StartDate']").val() == $("select[title='EndDate']").val()) 

However nothing happens. When debugging in developer tools , the script is not even loaded when the form loads.

Any ideas of what i'm doing wrong?

Thanks a lot!

  • Try to load your JSLink reference like ~sitecollection/..../furtherURL/... . E.g.~sitecollection/siteassets/--/--/HideEndDateDuration.js Oct 9 '17 at 10:09
  • In addition to above comment, i think that you need to have your jquery first as SharePoint renders the scripts from left to right in the jslink property. Oct 9 '17 at 10:37
  • Thanks for the replies. I have added an alert command before the $(document).ready(function() which executes. But the next jquery commands with the condition don't do anything.
    – shak
    Oct 9 '17 at 11:51
  • Possible solution to check: sharepoint.stackexchange.com/questions/82960/…
    – Pradip R.
    Oct 10 '17 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.