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

Below script is working fine in sharepoint default form while submit form but not in infopath form.

<script src="/images/prototype.js" type="text/javascript"></script>
<script src="images/SPUtility.js" type="text/javascript"></script>
<script type="text/javascript">

function PreSaveAction()
{
    if(my condition)
     return true;
    else
     return false;      
}

How to prevent submit in infopath form if my condition is false?

Thanks in Advance.

share|improve this question
    
What is the extension of a file which you called Infopath form and in which you have inserted this code? Is it .XSL, .XML, XSN, .ASPX, ...? Where and in which context? Which type of Infopath form? –  Gennady Vanin Геннадий Ванин Feb 19 '13 at 1:28
    
I'm using infopath form for sharepoint list. not default form. i have put content editor webpart and called js file for check validations. if my js return false then form should not be saved. –  Hitesh Chandegara Feb 19 '13 at 4:55
    
It is possible to do this codeless - with rules. If you want to do it through js, then you obviously should reconsider your requirements and probably your understanding what is Infopath for and how it is used –  Gennady Vanin Геннадий Ванин Feb 19 '13 at 6:26
    
it's not posible using rules. because i want to do some operations before submit form. –  Hitesh Chandegara Feb 19 '13 at 9:45
    
So, do it from Infopath code behind. If you still want to do it externally, in ASPX,then this question is not related to Infopath –  Gennady Vanin Геннадий Ванин Feb 19 '13 at 11:08

1 Answer 1

Please ask one question per post... Both are really duplicates to already asked and answered before questions

Infopath 2010 supports code-behind development only in C#.NET or VB.NET (2.0 or 2005), after installing VSTA (Visual Studio Tools for Applications) as part of Microsoft Office setup and except Sharepoint List Forms in which code-behind is not supported at all by Infopath. Javascript is not supported since Infopath 2003.

If to speak about usage of published Infopath forms as webparts in Infopath Web Part Pages, please check this answer.
And if to call external javascript from Infopath form, using NotifyHost, check msdn series of article: "Open a SharePoint Modal Dialog from an InfoPath Form: Part 1 of 5 (Vivek Soni)":

How to prevent submit in infopath form if my condition is false?

Please check this answer

share|improve this answer

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.