Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dynamically setting required/nillable attribute on textbox

6 views
Skip to first unread message

Helen

unread,
Jan 24, 2006, 1:57:02 AM1/24/06
to
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

unread,
Jan 24, 2006, 5:36:03 AM1/24/06
to
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

Helen

unread,
Jan 24, 2006, 11:52:06 AM1/24/06
to
that worked, thank you!

:)

Helen

0 new messages