Data Validation - Check boxes and Text boxes Question

J

jgrisi

I'd like to set an error message to appear if case of the following:
A check box value is TRUE (checked off), but the adjoining textbox is left
blank.

My condition is "Checkbox" = TRUE and "Textbox" is blank, then show this
error alert, dialog box alert "Error Message"

When I publish the form, I am able to check off the box and still leave the
form blank?

Help.

Thanks.
 
K

kfrost

Hello,

I'm not sure I fully understand your situation, but if I understand you
correctly you don't want the checkbox to stay select if there is no text in a
test field? I would think you would need to add code to an event such as
OnValidate for the text box.

I apologize but I don't know Infopath syntax well enough to show you an
example as to how to do it but in laymans terms,

Say you have a check box named chkCheck and a text field named txtText.

For txtText you create a validation with the following conditions:
chkCheck is equal to TRUE
txtText is blank

Select ok and in the Data Validation window, under Script, select probably
OnValidate and then Edit.

Enter your code here that will check /my:myFields/my:txtText and if blank,
change the value of /my:myFields/my:chkCheck = FALSE

I apologize for not giving you working code but I'm just now learning myself
how to utilize objects in Infopath with code.
 
J

jgrisi

Thanks.

Basically, If the check box is checked and the text box is blank, I want an
error to pop up. I should be able to do that without creating a script,
right?
 
K

kfrost

Ok, you made me pick up my book. I think you can. I kind of got this to
work by creating a rule for the checkbox.

I added 2 actions to the rule.
1) Show Dialog Box Message
2) Set a field's Value

For the second, for Field you use the checkbox Field. For the value I
inserted the following function, string("false").

That worked with a caveat. For some reason I got the message box twice that
I needed to enter in a value for the text box. You'll have to work that out
but it did give the popup you were looking for and then it set the checkbox
value to FALSE which means the checkbox was unchecked.
 
K

kfrost

P.S. Instead of using false for the value mentioned below just use the
number 0. However, for some reason I still get the dialogue box twice.

Hopefully that'll get you on the right track.
 
J

jgrisi

Thanks for all your help!

I'm actually running a demo version, testing it out before I put together a
proposal.

I'll try changing the values to 1 and 0.

I appreciate you picking up your book to help me out!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top