FormFieldValueFormat.FormatScript Property
Gets or sets the JavaScript to be performed before the field is formatted. This action may modify the fieldâs value before formatting. The scripts are in effect for PDF viewers that support JavaScript.
Namespace: DevExpress.Docs.Pdf
Assembly: DevExpress.Docs.Pdf.v26.1.dll
NuGet Package: DevExpress.Docs.Pdf
Declaration
Property Value
| Type | Description |
|---|---|
| String | A string that contains the JavaScript code to be executed before formatting the field. |
Example
How to: Specify a Value Format for a Form Field
The following code snippet executes a script that allows you to enter only numbers in the âx-x-xâ format:

using DevExpress.Docs.Pdf;
TextBoxField textField = new("TextField");
pdfDocument.Fields.Add(textField);
textField.ValueFormat = new FormFieldValueFormat {
FormatScript = "if (event.value != \"\") {" +
"var value = event.value; " +
"event.value = \"\"; " +
"for(var i = 0; i<value.length - 1; i++)" +
" event.value += value.charAt(i) + \"-\";" +
"event.value += value.charAt(value.length - 1);}",
KeystrokeScript = "var re = /^[0-9]+$/;" +
"if (event.value != \"\") {" +
" event.rc = re.test(event.value);" +
"}"
};
See Also