tshill4455 | Posts: 7

Text field numeric response only

0 votes

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


Attachments
Duo_Liang | Posts: 3776

Reply to: Text field numeric response only

0 votes

Hi 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


tshill4455 | Posts: 7

Reply to: Text field numeric response only

0 votes

Detailed steps would be great. I haven't explored the REST API calls yet but am willing to learn how to do that.  Thanks!


tshill4455 | Posts: 7

Reply to: Text field numeric response only

0 votes

I'm back from the holiday break. It would be great if I could get the detailed steps you mentioned.


Duo_Liang | Posts: 3776

Reply to: Text field numeric response only

0 votes

Hi 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"

1-3-2

Step2: Assuming you have such a layout

1-3-1

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":

1-3-3

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

1-3-4

 

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": ""
}

1-3-5

And this will update the field to restrict the text field to allow numeric only.

 

Duo


parkersEmma | Posts: 2

Reply to: Text field numeric response only

0 votes

Thanks for recomendation!


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off