0

I have a custom list inside sharepoint on-premises 2013, which have these fields:-

  1. Status. drop-down(Open,Closed).

  2. Type. drop-down(item,Box).

  3. Comment. Multiple line of text (allow pictures and tables).

  4. Actions. Multiple line of text (allow pictures and tables).

  5. Detailed Description. Multiple line of text (allow pictures and tables).

now i want to set this validation:-

  1. if the Status is set to Closed, then the user must enter values inside the Comment.

  2. if the Status is set to Closed and the Type = Box, then in-addition to the above case, the user must enter text inside the Actions and Detailed Description fields.

so i am not sure if i can benefit from the list validation to perform the above 2 validations?

0

List validation settings is not supported to validate value of a multiple-lines of text field.

If you want to validate value of a multiple-lines of text field, you need script to overwrite the PreSaveAction function by applying client-side validation.

Here is a demo for your reference: Introduction to Client Forms Validation in SharePoint 2013

0

you can try the below method that i have followed. You can write a PreSaveAction function and write your validation in the below function. Please find the example of the code.

<script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js">
   <script type="text/javascript">
   function PreSaveAction(){
   var Status =  $("select[title='Status']").val();
   var Type =   $("select[title='Type']").val();


      if (Status ==="Closed"){
        alert("Please Enter the comments below");
        $("input[title='Comment']").focus();
         return false;
           }    

            if(Status=== "Closed" && Type==="Box")
         {
        alert("Please Enter the details in Comment,Action,Details Description Field 
    ");
      $("input[title='Comment']").focus();
        $("input[title='Actions']").focus();
     $("input[title='Detailed Description']").focus();
     return false;
         }
      return true;
          }

Please mark the answer correct if it solved your issue.
Thanks!!!

Your Answer

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

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