Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / May 2006

Tip: Looking for answers? Try searching our database.

Date Picker --Need to pick Friday of the week

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gurmit - 02 May 2006 01:51 GMT
Hi, i'm new to infopath, i'm designing a simple timesheet form with a date
picker control. I want users to always pick Friday of the week(any week). If
user pick a date other than friday, it displays an error or something like
that. or if this is not possible can I put default value of date control as
Friday of the week.
Thanks,
Signature

Gurmit Singh

S.Y.M. Wong-A-Ton - 02 May 2006 18:51 GMT
Both are possible, but you'll have to write code to get this done.

- Add a date picker to your form and change its name to "date".
- Copy the isDay() function from
http://enterprise-solutions.swits.net/infopath/switch-day-sections-jscript-xdext
ensions.htm
to your form's code.
- Add an OnValidate event for the "date" field to your form's code and then
add the following code to this event handler:

if (!isDay(5))
{
 var objDate = XDocument.DOM.selectSingleNode("//my:date");
 eventObj.ReportError(objDate, "Date must be a Friday", false);
 return;
}

This code will prevent the form to be submitted unless the day is a Friday
and will show a red field validation error border around the "date" field and
a tooltip with the text "Date must be a Friday" whenever the user hovers with
the mouse pointer over the "date" field.

For more information on OnValidate and ReportError see
http://msdn.microsoft.com/library/en-us/ipsdk/html/xdevtOnValidate_HV01021372.as
p?frame=true

---
S.Y.M. Wong-A-Ton

> Hi, i'm new to infopath, i'm designing a simple timesheet form with a date
> picker control. I want users to always pick Friday of the week(any week). If
> user pick a date other than friday, it displays an error or something like
> that. or if this is not possible can I put default value of date control as
> Friday of the week.
> Thanks,
Gurmit - 02 May 2006 19:19 GMT
Thanks, this is a great help.
Signature

Gurmit Singh

> Both are possible, but you'll have to write code to get this done.
>
[quoted text clipped - 27 lines]
> > Friday of the week.
> > Thanks,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.