Validating Custom Fields
Validating a Custom Field in the Edit Screen
Main Script
lfInstantHook("textField", "LiveFields/hook.sil");
lfWatch("textField", {"textField"}, "LiveFields/hook.sil", {"keyup"}); |
Hook Script
if (argv["textField"] == "") {
lfShowFieldMessage("textField", "textField cannot be empty", "ERROR");
lfDisable("editSubmit");
lfDisable("createIssueSubmit");
} else {
lfHideFieldMessage("textField");
lfEnable("editSubmit");
lfEnable("createIssueSubmit");
} |
Using a Regular Expression for Validation
In the following example, the user must enter an value which matches a social security number.
Main Script
lfInstantHook("textField", "LiveFields/hook.sil");
lfWatch("textField", {"textField"}, "LiveFields/hook.sil", {"keyup"}); |
Hook Script
if (!matches(argv["textField"], "^\\d{3}-\\d{2}-\\d{4}$")) {
lfShowFieldMessage("textField", "You must enter digits in this format: XXX-XX-XXXX", "ERROR");
lfDisable("editSubmit");
lfDisable("createIssueSubmit");
} else {
lfHideFieldMessage("textField");
lfEnable("editSubmit");
lfEnable("createIssueSubmit");
} |
Additional Help
Need help implementing this script? Talk to me directly to me by clicking on the bot on this page.
Related articles
Filter by label
There are no items with the selected labels at this time.