Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Form Validation and Redirect

$
0
0

Hi Guys I have the following code that works but can you guys help me to modify so that:

it save email (person) to the list library.

goes to a differnet url on save and cancel goes to a different url

also check the form validation

Code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><script>
 $(document).ready(function(){
     var targetURL = 'YOUR URL';
     //For Cancel Button
   $("input[value='Cancel']").attr("onclick","location.href='" + targetURL +"';");  
     //For Save Button
       var saveButton = $("input[value='Save']");
       saveButton.removeAttr("onclick");
       saveButton.click(function() {
             if (!PreSaveItem()) return false;
             if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false; 
             var oldActionUrl = $('#aspnetForm').attr('action');
             var oldSource = GetUrlKeyValue("Source", true, oldActionUrl);           
             var newActionUrl = oldActionUrl.replace(oldSource, encodeURIComponent(targetURL));
     var elementName = $(this).attr("name");
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newActionUrl, false, true));
         });    
 });</script>


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>