FormFieldValueFormat.KeystrokeScript Property
Gets or sets the JavaScript to be performed when the user modifies a character in a. This action may check the added text for validity and reject or modify it.
Namespace: DevExpress.Docs.Pdf
Assembly: DevExpress.Docs.Pdf.v26.1.dll
NuGet Package: DevExpress.Docs.Pdf
Declaration
Property Value
| Type | Description |
|---|---|
| String | The keystroke JavaScript. For JS API reference, use JavaScript for Acrobat API Reference. |
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