Back to Devexpress

PdfAcroFormValueFormat.FormatScript Property

officefileapi-devexpress-dot-pdf-dot-pdfacroformvalueformat.md

latest2.7 KB
Original Source

PdfAcroFormValueFormat.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.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public string FormatScript { get; set; }
vb
Public Property FormatScript As String

Property Value

TypeDescription
String

The format JavaScript. For JS API reference, use JavaScript for Acrobat API Reference

|

Remarks

The code sample below shows how create a text box and specify the value format using JavaScript:

csharp
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);" +
    "}";
vb
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

PdfAcroFormValueFormat Class

PdfAcroFormValueFormat Members

DevExpress.Pdf Namespace