Workflow 7 Custom Validation on Text Box
Updated: 14 Feb 2011 | 6 comments
This issue has been solved. See solution.
Hello!
I'm trying to create custom validation for a workflow of mine. I want the custom validation to throw back a message if a user checks a check box but forgets to fill out the text box below it. I provided a small screenshot of the layout of what I'm referring to.
So...
If they check the box, but do not fill in the text box below it, when I press the Test button, I would like to notify the user. I know the validation must be simple, but I'm not sure how to do it.
Does anyone have an example of how to do this?
Discussion Filed Under:
Group Ownership:
Comments
Sure, you can write a custom
Sure, you can write a custom onclick event for the button.
1. Make the Control ID of the textbox "myTextBox" (no dbl quotes) under Functionality / Behavior
2. Make the Control ID of the checkbox "myCheckBox" (no dbl quotes)
3. For the button, add a AttributeKeyValuePair custom event to the Custom Events in Functionality / Behavior
Make the event onclick, and add the event handler script as follows (per your example - untested)
var myCheckBox = document.getElementById('myCheckBox'); //use control ID of checkbox in single quotes
var mytTextBox = document.getElementById('myTextBox'); //use control ID of textbox in single quotes
if((myCheckBox.checked && myTextbox.value == "") //may have to use myCheckBox.checked == 'true'
{
alert("Fill in your stuff!");
}
Here's a previous article where something similar is done: https://www-secure.symantec.com/connect/forums/add...
Is there a way to use the
Thanks, I'll give the script a try and see if it works!
No luck
I don't have the AttributeKeyValuePair as an option for custom events for the button component. I do have it for the checkbox and textbox though. Thoughts?
Disregard
Disregard AttributeKeyValuePair for the button component; just click Add, specify onclick, and away you go.
Another (convoluted) option is to incorporate this logic in the path the button follows on click. If the boolean output of the checkbox is true (true false rule), and the textbox output has no value (get text length), you can backtrack back to the form. If this was the case, I'd add an unpopulated error message label at the top of the form, then populate it with something meaningful if they ever backtrack to the form.
Custom Validation
You can also do this by enabling the Custom Validation option on the textbox component:
Then click the ellipsis button to edit the dialog model and set up the model like the following:
Takes a little longer to do but this will always work even if the user has javascripting disabled in their browser.
- Bruce
*** If a forum post solves your problem, please flag it as a solution. If you like an article or forum post, vote it up. ***
That worked!
Thanks matzebru. That little worklfow worked perfectly!
Would you like to reply?
Login or Register to post your comment.