PdfAcroFormValueFormat.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.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
#Property Value
Type | Description |
---|---|
String | The keystroke Java |
#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);" +
"}";