Text field numeric response only
Tuesday, December 21, 2021 at 01:57pmI have a document that I have applied a layout which includes a text box to enter a dollar amount. Is there a way to only allow a numeric response, no alpha characters? Or instead of saying 'Text Field' make it say 'Enter dollar amount'. It's government form so I can't really alter it in any way.
Reply to: Text field numeric response only
Tuesday, December 21, 2021 at 05:27pmHi tshill4455,
You can add an additional field validator which limits the text field to only accept numeric input. However, I don't think it's editable from UI directly, and you'll have to make REST API calls to achieve this goal. If you are interested, I can share the detailed steps for you to follow.
Duo
Reply to: Text field numeric response only
Wednesday, December 22, 2021 at 08:15amDetailed steps would be great. I haven't explored the REST API calls yet but am willing to learn how to do that. Thanks!
Reply to: Text field numeric response only
Monday, January 3, 2022 at 08:42amI'm back from the holiday break. It would be great if I could get the detailed steps you mentioned.
Reply to: Text field numeric response only
Monday, January 3, 2022 at 10:13amHi tshill4455,
The approach I am suggestion leverages the Interactive API Reference to facilitate the process of invoking APIs:
Step1: At the interactive API reference page, click the "Authorize" button and set the API Key as "Basic your_api_key"
Step2: Assuming you have such a layout
At the interactive API reference page > find the "Layouts" section > "GET /api/layouts" API > set the layout name as the parameter "search" and hit "Try it Out":
The response should return "count" 1 with the layout JSON, copy it to any text editor
Step3: In the JSON payload, you need to locate the text field and find below data:
-layout/package ID
-document ID
-approval ID (approval means signature in OneSpan Sign)
-field ID
Copy the field JSON to any text editor and modify the "validation" > "pattern" as "^[-+]?[0-9]*\\.?[0-9]*$", this regex expression means numeric input only
Step4: At the interactive API reference page > find the "Approvals" section > PUT /api/packages/{packageId}/documents/{documentId}/approvals/{approvalId}/fields/{fieldId}
Specify the four IDs as the parameter and the modified JSON as the request payload:
{
"binding": null,
"validation": {
"group": "",
"required": false,
"maxLength": null,
"disabled": false,
"errorMessage": "Please insert a number!",
"enum": null,
"minLength": null,
"minimumRequired": null,
"errorCode": null,
"pattern": "^[-+]?[0-9]*\\.?[0-9]*$"
},
"id": "AkZzA1tjf2QS",
"page": 0,
"data": null,
"subtype": "TEXTFIELD",
"width": 163.7999939918518,
"height": 36.39999866485596,
"fontSize": null,
"extract": false,
"formattedValue": "",
"left": 506.99998140335083,
"top": 447.19998359680176,
"extractAnchor": null,
"type": "INPUT",
"value": "",
"name": ""
}
And this will update the field to restrict the text field to allow numeric only.
Duo
Reply to: Text field numeric response only
Thursday, January 27, 2022 at 12:04pmThanks for recomendation!