I have to customize the NewForm and EditForm using JSLink. Perhaps there is another way of doing this.

So what I would like to know are these:

  1. How can I make a field required or not depending on condition? How do I set an asterisk next to the name of the field?

  2. How do I hide the entire row of the column, including the text depending on the condition?

So far I am using this blog

2 Answers 2


1st answer: This makes the field required and adds asterisk next to the column name.

  1. Go to Advanced Settings and Enable the Allow management of content types.

  2. Now you will see the content types associated with the list under the Settings section.

  3. Click on Item.

  4. Select the column.

  5. Check the Required radio button.

2nd answer:


Update to answer 1:

function PreSaveAction() { 
var reqfield = $("input[title='Required Column']").val(); 
 var status = $("input[title='Status Column']").val();
 if(status == 'condition'){ 
   if(reqfield== ""){ 
   $('nobr:contains("Required Column")').append('<span title="This is a required field." class="ms-accentText"> *</span>');              
   $("input[title='Required Column']").focus();        
   return false;
     return true;
     return true;
  • Thanks for your answer. Probably I was not that clear above. Because it is an Issue list, the field will be set required depending on the status of the issue. So, it will not be required all the time.
    – Imir Hoxha
    Commented Jun 18, 2015 at 15:57
  • I have updated my answer
    – Keerthi
    Commented Jun 18, 2015 at 16:14

JSLink is usually for displaying content in a different matter. What you may be looking for is to create a custom "NewForm" and "EditForm" using SharePoint Designer. Just open your site in SharePoint Designer, navigate to your list and create two custom forms. One for NewForm, and one for EditForm. Then you can add jquery and javascript logic to make a field required based on condition using the PreSaveAction method. Here is an example.

<script type="text/javascript">
 var $j = jQuery.noConflict(); 
 function PreSaveAction() { 
   var txtStatus = $j(":input[title='Status']").val(); 
   if(txtStatus == "In Progress"){        
   alert("Invalid Status");        
   var statusfocus = $j(":input[title='Status']");        
   statusfocus .focus();        
   return false;}
   return true;

Your Answer

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

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