Copy link to clipboard
Copied
Hello,
So I'm new to this. I have made it so a text field is required when a specific check box is checked. My issue is that when you uncheck the box, the text field remains required. I have researched and researched this, and I simply can't figure it out. I used the code below to make the text field requried when the box is checked. If anyone can help, that'd be fantastic!!!!!
var f = this.getField("Medicaid on")
f.required=true;
f.display = display.visible;
Copy link to clipboard
Copied
You can also run the same script as a mouse-up action from the checkbox field object:
var v = this.getField("myTextField");
var f= event.target;
if (f.value !="Off") {
v.required = true;
} else {
v.required = false;
}
Copy link to clipboard
Copied
+++EDITED REPLY
You mentioned asked about making a field required or not required based on the check or unchecked state of the checkbox.
Your script, however, is to hide or unhide the text field.
You can use the same script for that.
var v = this.getField("Text67");
var f= event.target;
if (f.value !="Off") {
v.display= display.visible;
} else {
v.display = display.hidden;
}
You can use something like this as the custom calculation script of the textfield where the field properties changes will take place:
var v = this.getField("myCheckBox");
var f= event.target;
if (v.value !="Off") {
f.required = true;
} else {
f.required = false;
}
Copy link to clipboard
Copied
You can also run the same script as a mouse-up action from the checkbox field object:
var v = this.getField("myTextField");
var f= event.target;
if (f.value !="Off") {
v.required = true;
} else {
v.required = false;
}
Copy link to clipboard
Copied
Or simply:
this.getField("myTextField").required = (event.target.value!="Off");

