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

Hide form in SP 2013

Jun 13, 2014 at 2:32 PM
I have field:
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
And want hide another when FieldName="Title" is empty.
<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="Miasto" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Miasto')}"/>
I used code from another discussion and past it after <asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">.
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="../../javascript/sputility.min.js"></script>
function OnCountryFieldDropdownChange(spfield) {
    var countryFieldValue = spfield.GetValue(); 
    // Hide the City field if the selected value is Other 
    if(countryFieldValue === 'Polska') { 
    } else{ 

    // Get a single select dropdown field 
    var countryField = SPUtility.GetSPField('Title');
    // whenever the field's dropdown changes, check whether we need to show or hide
    $(countryField.Dropdown).on('change', function() { 
    // run it once when the form loads to show/hide the field
But it dont work, can i someone help?
Jun 22, 2014 at 8:06 PM
Seems like you are creating a custom form in SharePoint designer? Unfortunately, SPUtility won't work with custom forms. It will only work with the out of the box SharePoint forms.
Jun 23, 2014 at 9:56 AM
Hello KitMenke,
did you mean the script will not work if we added it in the list forms with SharePoint designer? I had the same issue as Karol, when I tried to added the script to the list forms with designer, it didn't work. And I also tried to added the customized code with the content editor web part in the list forms, but it cannot be saved due to some must filled columns defined in the list before. How can we handle this? Could you please give us some ideas? Thanks in advance.
Jun 23, 2014 at 11:37 AM
Yep, I made new form (add form) in designer because in this way is easier for make own graphic than in infopath. Like jhyshuixin I prefers add code at page, when I edit form and so i have to edit source.
Too bad it does not work, its lovley and simple but very useful script. Keey finger for update :)
Jun 24, 2014 at 12:20 AM
Edited Jun 24, 2014 at 12:21 AM
If you can use the Content Editor Web Part that is ideal because you can just add it on the same page along with the form.

To get around the required field problem, you can try just putting a value in the field (to make the validation happy) and then "stop editing". It should save your page then without actually creating/editing an item.

For the graphics, you can also put that in a CEWP at the top/bottom of your form rather than use SharePoint Designer. However, I understand that it doesn't give you as much control as SPD does. You can still use JavaScript on your form using jQuery but SPUtility won't work because it is coded to work with the default forms. :)