Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Forum Post: RE: Date/Time control - stop users from select before and after times

$
0
0
Hi Chris, Please find below code to achieve the required : Steps : 1. Add the fuction in Web resource JS file of form. Call the function on save of form. 2. Replace your Date & Time field name in place of "new_datetime". 3. When doing setting of save function pass context as first parameter. function getdate(context){ var dateFieldValue = Xrm.Page.getAttribute("new_datetime").getValue(); // create the yyyy-mm-dd string var year = dateFieldValue.getFullYear()+""; var month = (dateFieldValue.getMonth()+1)+""; var day = dateFieldValue.getDate()+""; var hours = dateFieldValue.getHours()+""; var min = dateFieldValue.getMinutes()+""; var dateFormat = year + "-" + month + "-" + day + "-" + hours + "-" + min; if (hours 17 ) { alert("Date Time cannot be less than 9:00AM and greater than 5:00PM)"); context.getEventArgs().preventDefault(); return false; } } Hope this helps !! Let me know if you need any more assistance on same. Please mark my answer as verified if it helped. Thanks Regards, Kamran

Viewing all articles
Browse latest Browse all 71679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>