XPage CheckBoxGroup/RadioGroup/Select server-side validation: Is there an easier way than this?

In order to perform server-side validations on a radio group/checkbox group I had to write client-side JavaScript that copies the selected values from the radio/checkbox into a hidden inputbox field (which had to be hidden via css) and then set up server-side validation for the hidden inputbox plus then connect both the radio group/checkbox group to the same data field in the data source. Ugh!

In order to validate a select object I needed to use a validateExpression validator.

There must be an easier way to do this.

Anybody else have easier ways to server-side validate these kinds of fields? Please? Pretty please?

Subject: John, thanks but…

John,

First, thanks for your response.

Second, thanks for your blog. I have found several of your XPages postings to be very helpful.

Third, we both ended up using validators for the select but I like your solution better.

Finally,I guess “works” means different things to different folks. You are correct that you will get the standard “Validation Error: Value is required” message by simply working with the properties but that is not a viable solution long term. “Works” to me means the message is customized.

Subject: Customize the error message

Sorry, I guess I misunderstood. So the issue is that you want to customize the error message from a checkbox/radiobutton group?

If that’s the case, I thought you could just add a “validateRequired” validator and add your custom message there…but I could not get that to work for me either.

I’ll spend some time on it.

-John

Subject: I think this is a bug…

It works for an Editbox control but not checkbox group, radiobutton group, or listbox. Those are the only ones I tried so far.

Anyone else have a different approach?

John

Subject: I think you are right…

…I found another thread and Paul Hannan indicated that this is a bug impacting other controls and he stated that all controls should have the same functionality for validation messages.

Subject: This is the bug - PHAN7PRL37 - to be fixed in 8.5.1

validateRequired doesn’t display custom error message for listBox, radioGroup or checkBoxGroup controls

Subject: hmmmm 8.5.1??

Server or DDE? because I’m running 8.5.2 DDE and 8.5.1 server and no validation works for combo boxes AT ALL, and radio buttons don’t get the customized message, but at least do work. Any additional info out there??

Subject: Still a bug as of 8.5.3

Subject: I set the required property

Hi Russell,

Are you just checking if they user selected a value? If so, I just set the “required” property to true. Then link a “Display Error” control to the checkbox group or radio button group.

The only control that this did not work for me is a combobox where I set the default value to “-Select-”. Then I needed to use a validateconstraint validator and a regular expression “^(?!.-Select-)[-a-zA-Z\d .,/]$”

Here’s that code:

					<xp:this.validators>





							<xp:validateConstraint

								message="Validation Error: Value is required.">



								<xp:this.regex><![CDATA[^(?!.*-Select-)[-a-zA-Z\d .,/]*$]]></xp:this.regex>

							</xp:validateConstraint>

						</xp:this.validators>

-John