in my model i have a field like expected_start_date__c. this date should be future date. how to write snippet code for this validation. Thanks in advance
Hi raj
This is pretty simple. You just need to compare the two dates using common operators:
var today = new Date(), tomorrow = new Date();<br />tomorrow.setDate(tomorrow.getDate() + 1);<br />console.log(today > tomorrow); //false<br />console.log(today < tomorrow); //true<br />console.log(today == tomorrow); //false
Try it out and play with it. Alter the script to fit your needs and you should be good to go.
Cheers
my requirement for that field is , if that field is null or undefined or past date, then i want throw error message.how to add the future date in if condition
if (Startdate === ‘’ || Startdate === null || Startdate === undefined ) {
editor.handleMessages(
<{
message: ‘Please Enter Expected start date and Expected date should be future date’,
severity: ‘ERROR’
}]
);
return false;
}
raj, you need to get your salesforce date into javascript and then compare it to a new Date().
take a look at http://help.skuidify.com/m/11720/l/129505-skuid-time
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.