Sharepoint 2013 Custom List Edit form Validation:not saving List Item after applying validation on PreSaveAction


I am trying to validate sharepoint custom list edit form on the basis of sharepoint  security group on PreSaveAction
my conditions are:
1-If User from 'UserGroup' than it it will ask to fill Request Descripton ,return false
2-if user from other group then it will ask to fill Response description, return false
3- if above condition fullfills then it will  return true

my code(below) is working fine for 1 and 2nd condition but fails to execute 3rd condition?

I am using the below code in script editor Web Part on Edit form.

<script type="text/javascript">
function PreSaveAction(){
   var returnval=true;
                operation: "GetGroupCollectionFromUser",
                userLoginName: $().SPServices.SPGetCurrentUser(),
                async: false,
                completefunc: function (xData, Status) {
                    $(xData.responseXML).find("Group").each(function () {
                        var groupname=$(this).attr('Name');
var itemTitle = $("textarea[title='Request Description']").val();
var response = $("textarea[title='ResponseDescription' ]").val();
if(groupname=='UserGroup' && itemTitle=='' && itemTitle.length < 1 )

            alert("Kindly fill the Request Description");
            $("textarea[title='Request Description']").attr("style", "border: solid 1px #ff4c42 !important");


if(response=='' && response.length < 1 )


            alert("Kindly fill the ResponseDescription");
            $("textarea[title='ResponseDescription']").attr("style", "border: solid 1px #ff4c42 !important");


return returnval;




May 29th, 2015 1:22am


Per my understanding, you might want users fill different fields based on the group they belong to.

As a common practice, I suggest debug the code in browser and make tests with different accounts to go through each possible scenarios of the code logic, it will make you easier to find out the issued line of code. 

About how to debug JavaScript using IE Developer Tools for your reference:

Feel free to reply if there is any progress.

Free Windows Admin Tool Kit Click here and download it now
May 31st, 2015 1:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics