officefileapi-devexpress-dot-pdf-dot-pdfacroformvalueformat.md
Gets or sets the JavaScript to be performed before the field is formatted. This action may modify the field’s value before formatting.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public string FormatScript { get; set; }
Public Property FormatScript As String
| Type | Description |
|---|---|
| String |
The format JavaScript. For JS API reference, use JavaScript for Acrobat API Reference
|
The code sample below shows how create a text box and specify the value format using JavaScript:
var scriptBox =
new PdfAcroFormTextBoxField("script", 1, new PdfRectangle(10, 170, 100, 200));
scriptBox.ValueFormat = new PdfAcroFormValueFormat();
//Specify a script that allows you to enter only numbers
//in the "x-x-x" format:
scriptBox.ValueFormat.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);}";
scriptBox.ValueFormat.KeystrokeScript = "var re = /^[0-9]+$/;" +
"if (event.value != \"\") {" +
" event.rc = re.test(event.value);" +
"}";
Dim scriptBox =
New PdfAcroFormTextBoxField("script", 1, New PdfRectangle(10, 170, 100, 200))
scriptBox.ValueFormat = New PdfAcroFormValueFormat()
'Specify a script that allows you to enter only numbers
'in the "x-x-x" format:
scriptBox.ValueFormat.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);}"
scriptBox.ValueFormat.KeystrokeScript = "var re = /^[0-9]+$/;" & "if (event.value != """") {" & " event.rc = re.test
See Also