.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> SharePoint >> Post New QuestionBookmark and Share Subscribe to Forum

PreSaveAction() in sharepoint cutom list

Posted By: Aruna     Posted Date: December 22, 2010    Points:2   Category :SharePoint
Hi,
I write the below code to compare various date formats. i am facing a strange behavior in arrDate5 am gettin the current date and compare with the field value. for every month wen i select the date between 3 and 9 its showing the selected date is greater than the current date. the value of current date is (22-dec-10).
did i am missing something

<script language="javascript" type="text/javascript">
function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++)
{
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
{
return tags[i];
}
}
return null;
}
function PreSaveAction()
{
var date1 = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Issued Date");
var date2 = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Expiry Date");
var date3 = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Date of Stamping");
var date4 = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","VISA Expiry Date");

var d = new Date();



var country=getTagFromIdentifierAndTitle("SELECT","DropDownChoice","VISA Country");
var type=getTagFromIdentifierAndTitle("SELECT","DropDownChoice","VISA Type");





var arrDate1 = date1.value.split("/");
var useDate1 = new Date(arrDate1[2], arrDate1[1]-1, arrDate1[0]);
var arrDate2 = date2.value.split("/");
var useDate2 = new Date(arrDate2[2], arrDate2[1]-1, arrDate2[0]);
var arrDate3 = date3.value.split("/");
var useDate3 = new Date(arrDate3[2], arrDate3[1]-1, arrDate3[0]);
var arrDate4 = date4.value.split("/");
var useDate4 = new Date(arrDate4[2], arrDate4[1]-1, arrDate4[0]);
var arrDate5= (d.getMonth()+1) +(",") + d.getDate()+ (",")+ d.getFullYear();


if(useDate1 >= useDate2)
{
alert("Expiry Date cannot be greater than or equal to Issued Date");
return false;
}
else if(useDate3 >= useDate4)
{
alert("VISA Expiry date cannot be greater than or equal to Date of Stamping");
return false; // Cancel the item save process
}
else if(arrDate1 > arrDate5)
{
alert("Issue Date cannot be greater than the Current Date");
return false;
}
else if(type.value.length>0)
{
if(country.value==0)
{

alert("Choose VISA Country");
return false;
}
}




return true; // OK to proceed with the save item

}
</script>




Responses

No response found. Be the first to respond this post
Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend