DynaPDF.SetNumberFormat
-----------------------

Limits textfield to only accept numbers.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [6.4](newinversion64.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetNumberFormat"; PDF; Field; Sep; DecPlaces; NegStyle { ; CurrStr; Prepend } ) 

**MBS**( **"DynaPDF.SetNumberFormat";** /\* Limits textfield to only accept numbers. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Field**; /\* The field index or field name.e.g. "FirstName" \*/   
**$Sep**; /\* The decimal separator.  
Can be CommaDot, NoneDot, DotComma or NoneComma.e.g. "CommaDot" \*/   
**$DecPlaces**; /\* Number of decimal placese.g. 2 \*/   
**$NegStyle**; /\* Negative number format.  
Can be MinusBlack, Red, ParensBlack or ParensRed.e.g. "ParensRed" \*/   
**$CurrStr**; /\* Optional; The currency string.  
Or empty for no currency.e.g. "€" \*/   
**$Prepend**) /\* Optional; Position of Currency string.  
Pass 1 to prepend or 0 to append.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| Field | The field index or field name. | "FirstName" |  |
| Sep | The decimal separator.   Can be CommaDot, NoneDot, DotComma or NoneComma. | "CommaDot" |  |
| DecPlaces | Number of decimal places | 2 |  |
| NegStyle | Negative number format.   Can be MinusBlack, Red, ParensBlack or ParensRed. | "ParensRed" |  |
| CurrStr | The currency string.   Or empty for no currency. | "€" | Optional |
| Prepend | Position of Currency string.   Pass 1 to prepend or 0 to append. | 0 | Optional |

### Result

Returns OK or error.

### Description

Limits textfield to only accept numbers.  
The function restricts the allowed input characters of a text field to numbers and formats the resulting string as specified. A number format is represented as two separate JavaScript Actions in PDF which are automatically created and added to the text field by this function.   
The same formats can also be applied manually by creating two JavaScript actions: one for the OnKeyStroke event, and one for the OnFormat event of the text field. See [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md)() for a description of the events.   
DynaPDF uses the [JavaScript](component_JavaScript.md) functions AFDate\_Keystroke() / AFDate\_KeystrokeEx() or AFDate\_Format() / AFDate\_FormatEx() to apply a number or date format. The functions are described in the JavaScript scripting reference which is available at http://www.adobe.com.   
See also [SetNumberFormat](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetNumberFormat.shtml) function in DynaPDF manual.

### Examples

Create field for numbers:

 Set Variable \[$f ; Value:MBS ("[DynaPDF.CreateTextField](DynaPDFCreateTextField.md)"; $pdf ; Create Form::Name ; -1; Create Form::Multiline ; Create Form::MaxLen ; Create Form::PosX ; Create Form::PosY ; Create Form::Width ; Create Form::Height )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.SetTextFieldValue](DynaPDFSetTextFieldValue.md)"; $pdf ; $f ; Create Form::Value ; Create Form::DefaultValue )\]  
Set Variable \[$r ; Value:MBS ("DynaPDF.SetNumberFormat"; $pdf ; $f ; "CommaDot"; 2; "Red"; "€"; 0)\]  
### See also

- [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md)
- [DynaPDF.CreateJSAction](DynaPDFCreateJSAction.md)
- [DynaPDF.CreateListBox](DynaPDFCreateListBox.md)
- [DynaPDF.CreateTextField](DynaPDFCreateTextField.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetPageFormat](DynaPDFSetPageFormat.md)
- [DynaPDF.SetTextFieldValue](DynaPDFSetTextFieldValue.md)

### Example Databases

- [DynaPDF/Create PDF with sum form field](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20PDF%20with%20sum%20form%20field.shtml#2ScriptAnchor_)

### Blog Entries

- [Tip of the day: DynaPDF form creation with calculation with FileMaker](https://www.mbsplugins.de/archive/2016-08-24/Tip_of_the_day_DynaPDF_form_cr/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 16th August 2016 , last changed 16th August 2016

  
[DynaPDF.SetNeedAppearance](DynaPDFSetNeedAppearance.md) - [DynaPDF.SetOCGState](DynaPDFSetOCGState.md)

[HTML Version](DynaPDFSetNumberFormat.shtml)