Stump the Panel: SharePoint Q&A

Immediate solutions for common SharePoint questions
It is currently Sat May 18, 2013 6:31 am

All times are UTC - 5 hours [ DST ]


Forum rules


What you are viewing is an archive of Stump the Panel. It remains for reference purposes. Please post all new questions on NothingButSharePoint.com
https://www.nothingbutsharepoint.com/sites/eusp/Forum



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Sharepoint Designer PreSaveAction()
PostPosted: Sat Mar 26, 2011 10:18 am 
Offline

Joined: Fri Jul 16, 2010 8:54 am
Posts: 85
HI all,

I am writing a PreSaveAction function for javascript validation on Custom List Form as below:

Code:
function PreSaveAction(){
var ddlTtype = getTagFromIdentifierAndTitle("select","LookUp","Ticket Type"); 
var sub1 = getTagFromIdentifierAndTitle("INPUT","TextField","Subject");
var desc1= getTagFromIdentifierAndTitle("TextArea","TextField","Comment"); 
        if (ddlTtype.value=="" || sub1.value == "" || desc1.value == "")
    { 
        alert("Please Complete all the Required fields"); 
        return false; // Cancel the item save process 
    } 
   
   if(confirm("Do you want to continue with this information?")==true)
   {
   
    alert("Successfully Submitted");
    return true; // OK to proceed with the save item
       
    }
   
    return false;
   


In this for "SingleLineText" (Subject field) the validation works perfectly before PreSaveAction, but i'm not getting the way to validate the Dropdown or lookup and MultiLineText....

and my fields in design the control looks as below:
For field Ticket Type:(which is a Lookup)

Code:
<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Ticket_x0020_Type" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Ticket_x0020_Type')}"/>
                     <SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="Ticket_x0020_Type" ControlMode="New"/>


For field Subject:(SingleLineText)

Code:
<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="Subject" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Subject')}"/>
                     <SharePoint:FieldDescription runat="server" id="ff3description{$Pos}" FieldName="Subject" ControlMode="New"/>


For field Description:(MultiLineText)

Code:
<SharePoint:FormField runat="server" id="ff4{$Pos}" controlmode="New" fieldname="Comment" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Comment')}" />
                     <SharePoint:FieldDescription runat="server" id="ff4description{$Pos}" FieldName="Comment" ControlMode="New"/>


Please help me on this....

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Sharepoint Designer PreSaveAction()
PostPosted: Sat Mar 26, 2011 7:26 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 6:02 pm
Posts: 1035
Location: Silver Spring, MD
Try this out. It wraps all of your return false/true statements into the same logical test. Should clear up any errors you are having.
Code:
function PreSaveAction() {
   var ddlTtype = getTagFromIdentifierAndTitle("select","LookUp","Ticket Type");
   var sub1 = getTagFromIdentifierAndTitle("INPUT","TextField","Subject");
   var desc1= getTagFromIdentifierAndTitle("TextArea","TextField","Comment");

   if ( ddlTtype.value=="" || sub1.value == "" || desc1.value == "" ) {
      alert("Please Complete all the Required fields");
      return false; // Cancel the item save process
   } elseif confirm("Do you want to continue with this information?") == true ) {
      alert( "Successfully Submitted" );
      return true; // OK to proceed with the save item
   } else {
      return false;
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group