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 / January 2006

Tip: Looking for answers? Try searching our database.

dynamically setting required/nillable attribute on textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Helen - 24 Jan 2006 06:57 GMT
Hi,

I have a drop down list in an infopath form, and based on the value selected
I want to make the next field - a textbox required.

I have created an onafterchange event using js
the if statement works
i.e.
if(XDocument.DOM.selectSingleNode("/my:myFields/my:first_submission/my:group6/my:ddlRequestType").text != "New Requirement")
but I can't seem to find the syntax to assign a required value to the textbox

I have read the xsd, xml and xsl and don't see where these attributes are
saved as other required fields on the page don't differ in syntax from
nonrequired fields

any suggestions?
S.Y.M. Wong-A-Ton - 24 Jan 2006 10:36 GMT
Try using the ReportError method of the event object in the OnValidate event
for the dropdown and pass the node for the textbox to the ReportError method.
Do something like the following:
---
var node1 = XDocument.DOM.selectSingleNode("my:myFields/my:field1")
var node2 = XDocument.DOM.selectSingleNode("my:myFields/my:field2")
   
if (node1 != null && node2 != null)
{
 if (node1.text != "New Requirement" && node2.text == "")
 {
   eventObj.ReportError(node2, "required", false);
 }
}

Where field1 is the dropdown and field2 the textbox.

NOTE: You do not need custom code to perform field validation; you can set
validation conditions on fields through the design interface of InfoPath.
---
S.Y.M. Wong-A-Ton

> Hi,
>
[quoted text clipped - 12 lines]
>
> any suggestions?
Helen - 24 Jan 2006 16:52 GMT
that worked, thank you!

:)

Helen

> Try using the ReportError method of the event object in the OnValidate event
> for the dropdown and pass the node for the textbox to the ReportError method.
[quoted text clipped - 34 lines]
> >
> > any suggestions?
 
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.