Friday, July 9, 2010

SharePoint 2007 Start Date End Date Validation in List forms with JavaScript

SharePoint 2007 Start Date End Date Validation in List forms with JavaScript:

<script language="javascript"> 
function PreSaveAction()
{
var blFlag;
blFlag = true;

var SOSOccDate = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Date SOS Occurred"); 

var DUEDate = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Due date"); 

var dtSOSOccDate = new Date(SOSOccDate.value);
var dtDUEDate = new Date(DUEDate.value);
var TodaysDate = new Date();

if(dtSOSOccDate != null)
{
if(dtSOSOccDate > TodaysDate)
{
alert("Date SOS Occured cannot be greater than today's date");
}
}

if(DUEDate.value != "")
{
if(dtDUEDate < dtSOSOccDate)
{ 
alert("The Due date cannot happen earlier than the SOS occurred date"); 
blFlag = false; // Cancel the item save process 
}
}
return blFlag; // OK to proceed with the save item 
}
</script>



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...