---
title: "Validating Custom Fields"
canonical: "https://support.appfire.com/space/SUPPORT/80878096/Validating%20Custom%20Fields"
format: markdown
---
## 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");
}
``` |


![image](media://6f9893c0-7c97-434a-bde4-fdbe43e00d28)

## 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");
}
``` |

  


![image](media://2f8f4930-65a8-48d2-ab1f-051d0f0c82fd)

 

## Additional Help

Need help implementing this script? Talk to me directly to me by clicking on the bot on this page.

## Related articles



> Macro (contentbylabel)

> Macro (details)
> 
> | Related issues |  |
> | --- | --- |