Skip to end of banner
Go to start of banner

Validating Custom Fields

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

We've encountered an issue exporting this macro. Please try exporting this page again later.

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.

Filter by label

There are no items with the selected labels at this time.

  • No labels