I want to perform a validation for today's date and user entered date in my custom list form's multiple datetime fields
if RecvdDate>=Today , I need to prevent user from saving the form- presaveaction
call.
Also DueByDate field, which has to be greater than ReqstRecvdDate Field. I added the below code, but the validation is not working when
a) I selected 31-Oct-2015 as ReqstRecvdDate & I selected DueByDate field as 01-Dec-2015. As per the rule it's set to true and should allow me to save the form, but this didn't happen.
<script language="javascript"
src="/project/EASAssetsLib/jquery-1.6.0.min.js"
type="text/javascript"></script><script language="javascript"
src="/project/EASAssetsLib/jquery.SPServices-
2014.01.min.js" type="text/javascript"></script><script
language="javascript"
src="/project/EASAssetsLib/prototype.js"
type="text/javascript"></script><script language="javascript"
src="/project/EASAssetsLib/SPUtility.js"
type="text/javascript"></script><script language="javascript"
type="text/javascript">
function PreSaveAction()
{
var reqstrecvddatethrusputility = SPUtility.GetSPField('Request
Received Date').GetValue();
var reqsteDateStr=reqstrecvddatethrusputility.toString();
var mon1 = reqsteDateStr.substring(0,2);
var dt1 = reqsteDateStr.substring(3,5);
var yr1 = reqsteDateStr.substring(6,10);
temp1 = mon1 + "/" + dt1 + "/" + yr1;
var dtReqstRecvdDate = new Date(temp1);
var reqstRecvdDateInUTC = dtReqstRecvdDate.toUTCString();
var currentTime = new Date();
var CurDateInUTC = currentTime.toUTCString();
dt3 = new Date(reqstRecvdDateInUTC);
dt4 = new Date(CurDateInUTC);
if(dt3 > dt4 )
{
alert('Received Date cannot be greater than Todays
Date!');
return false;
}
Due to some reason,month range is not getting recognized properly.
What I need to change in my code to do the right validation?