A simple “day of the week” script

Some months ago a customer asked us if it was possible to prevent users from selecting a Saturday or Sunday in a date field. Here is a simple function you can use to call the selected day of the week. You can customize it to suit your own wishes. Please remember that Sunday is 0 and Saturday is 6.

Happy Easter!

function weekday () {
//Script to show which weekday the selected date is.
//Sunday = 0, Saturday = 6
//Script to be called during Onchange event

/* CRM 3.0 & 4.0 */ selectedDate = crmForm.all.estimatedclosedate.DataValue;
/* CRM 2011 */ selectedDate = Xrm.Page.data.entity.attributes.get("estimatedclosedate");
var weekday = selectedDate.getDay();
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

alert("You have selected a " + dayNames[weekday]);
}
Tagged as: , , ,

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars (2 votes, average: 6.00 out of 7)
Loading ... Loading ...

Comments are closed.

  • Recent Posts

  • Ratings

  • Archive

  • Admin

  • Cloud

  • Microsoft Certified Professional

  • About & Contact