Skip to main content
All docs
V26.1
  • 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.v26.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public string FormatScript { get; set; }

    Property Value

    Type Description
    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:

    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);" +
        "}";
    
    See Also