Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do i add javascript to the form library new form, since i published infopath form as default form page.

I am using sharepoint 2013 and infopath 2013 to customize the form. Is there any way to add script/ jquery to theform.

IS Sharepoint designer is the only option?

share|improve this question

1 Answer 1

yes you can, check the link out below:

http://blogs.msdn.com/b/infopath/archive/2010/03/18/introduction-to-programming-in-infopath-2010.aspx

its too big to go through to post here! bottom line is you need to add codebehind and add

private string BindScript(string ScriptUrl, bool PickFromSiteCollection)
{
    if (PickFromSiteCollection)
        ScriptUrl = Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(SPContext.Current.Site.RootWeb.Url, ScriptUrl);
    else
        ScriptUrl = Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(SPContext.Current.Web.Url, ScriptUrl);
    return string.Format(@"<script type=""text/javascript"" src=""{0}""></script>", ScriptUrl);
}

call the above method in an event that you require (override) like onload or onsubmit ect

writer.Write(BindScript("/_layouts/1033/js/jquery.min.js", true));
share|improve this answer
    
sorry ali...i couldnot use the code in the infopath since client is not allowed to do so....is there any solution apart from this –  Arul Aug 20 '13 at 5:21
    
when you say not allowed to do so how do you mean exactly? asin hasnt get the right privligaes to run code? –  ali Sharepoint Aug 21 '13 at 10:39
    
Ali...i have to do jquery in submit action....if so...i need to use edit code option...which will take me to custom code...which i am not suppose to do as per client requirement.... –  Arul Aug 21 '13 at 15:03
    
tell me if so any solution....or let me know if i m not right –  Arul Aug 21 '13 at 15:04
    
add content editor and edit in html.put your javascript there. –  SharePointer Mar 13 '14 at 4:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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