How to add validation to the textbox form field via API?

When using the textbox form field, you have the option to include validation based on your needs, which will specify the type of text that signers can enter in the field. The available options are only numbers, regex, currency, email, and none.

Only Numbers: Signers can only enter numeric numbers in the textbox area.

Regex: Customize the validation by selecting the regex option, entering the desired regex value, and adding a description to inform signers of the needed format.

Email: Restrict email input to the textbox area.

Currency: The signer can only input currency values in the textbox area.

Adding Only Numbers Validation using API

The following sample code snippet demonstrates how to add only number validation to a textbox field:

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Message={your message}' \
  -F 'Signers={
    "name": "starvritsa",
    "emailAddress": "starvritsabuhungi@boldsign.dev",
    "privateMessage": "sign",
    "authenticationType": "None",
    "deliveryMode": "Email",
    "signerType": "Signer", 
 
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "Textbox",
            "pageNumber": 1,
            "bounds": {
                "x": 140,
                "y": 140,
                "width": 82,
                "height": 32
            },
            "isRequired": true,
            "validationType": "NumbersOnly"
        }
    ]
}' \
  -F 'Files=@{Your file path};type=application/pdf' \
  -F 'Title={Document title}' \

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);
 
var documentFilePath = new DocumentFilePath
{
   ContentType = "application/pdf",
   FilePath = "{file path}",
};
 
var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};
 
var signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type: Type.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50),
    validationType: "NumbersOnly");

var formFieldCollections = new List<FormField>()
{
    signatureField
};
 
var signer = new DocumentSigner(
  signerName: "David",
  signerType: SignerType.Signer,
  signerEmail: "starvritsabuhungi@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);
 
var documentSigners = new List<DocumentSigner>()
{
    signer
};
 
var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Signers = documentSigners,
   Files = filesToUpload,
 
};
var documentCreated = documentClient.SendDocument(sendForSign);


import requests
import json
 
url = "https://api.boldsign.com/v1/document/send"
 
signer_data = {
    "name": "hanky",
    "emailAddress": "starvritsabuhungi@boldsign.dev.com",
    "signerType": "Signer",
    "signerRole": "Signer",
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "TextBox",
            "pageNumber": 1,
            "bounds": {
                "x": 100,
                "y": 100,
                "width": 200,
                "height": 200
            },
            "isRequired": True,
            "validationType":"NumbersOnly"
        }
    ],
    "locale": "EN"
}
 
payload = {
    'Signers': json.dumps(signer_data),
    'Title': "Agreement",
}
 
files = [
     ('Files', ('{file name}', open('{file path}', 'rb'), 'application/pdf'))
]
 
headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}
 
response = requests.post(url, headers=headers, data=payload, files=files)
 
print(response.text)

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

let data = new FormData();

data.append('Signers', '{\r\n        "name": "starvritsa",\r\n        "emailAddress": "starvritsabuhungi@syncfusion.com",\r\n        "signerType": "Signer", \r\n        "signerRole": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "textbox1",\r\n                "name": "textbox1",\r\n                "fieldType": "TextBox",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 100,\r\n                  "y": 100,\r\n                  "width": 125,\r\n                  "height": 25\r\n                   },\r\n      "isRequired": true,\r\n    "validationType":"NumbersOnly"\r\n  }\r\n  ],\r\n  "locale": "EN"\r\n}');

data.append('Files', fs.createReadStream('{you file path}'));

data.append('Title', 'Node JS validation');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'X-API-KEY': '{your api key}', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


Adding Email Validation to Textbox field using API

The following sample code snippet demonstrates how to add Email validation to a textbox field:

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Message={your message}' \
  -F 'Signers={
    "name": "starvritsa",
    "emailAddress": "starvritsabuhungi@boldsign.dev",
    "privateMessage": "sign",
    "authenticationType": "None",
    "deliveryMode": "Email",
    "signerType": "Signer", 
 
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "Textbox",
            "pageNumber": 1,
            "bounds": {
                "x": 140,
                "y": 140,
                "width": 82,
                "height": 32
            },
            "isRequired": true,
            "validationType": "EmailAddress"
        }
    ]
}' \
  -F 'Files=@{Your file path};type=application/pdf' \
  -F 'Title={Document title}' \

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);
 
var documentFilePath = new DocumentFilePath
{
   ContentType = "application/pdf",
   FilePath = "{file path}",
};
 
var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};
 
var signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type: Type.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50),
    validationType: "EmailAddress");

var formFieldCollections = new List<FormField>()
{
    signatureField
};
 
var signer = new DocumentSigner(
  signerName: "David",
  signerType: SignerType.Signer,
  signerEmail: "starvritsabuhungi@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);
 
var documentSigners = new List<DocumentSigner>()
{
    signer
};
 
var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Signers = documentSigners,
   Files = filesToUpload,
 
};
var documentCreated = documentClient.SendDocument(sendForSign);

import requests
import json
 
url = "https://api.boldsign.com/v1/document/send"
 
signer_data = {
    "name": "hanky",
    "emailAddress": "starvritsabuhungi@boldsign.dev.com",
    "signerType": "Signer",
    "signerRole": "Signer",
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "TextBox",
            "pageNumber": 1,
            "bounds": {
                "x": 100,
                "y": 100,
                "width": 200,
                "height": 200
            },
            "isRequired": True,
            "validationType":"EmailAddress"
        }
    ],
    "locale": "EN"
}
 
payload = {
    'Signers': json.dumps(signer_data),
    'Title': "Agreement",
}
 
files = [
     ('Files', ('{file name}', open('{file path}', 'rb'), 'application/pdf'))
]
 
headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}
 
response = requests.post(url, headers=headers, data=payload, files=files)
 
print(response.text)

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

let data = new FormData();

data.append('Signers', '{\r\n        "name": "starvritsa",\r\n        "emailAddress": "starvritsabuhungi@syncfusion.com",\r\n        "signerType": "Signer", \r\n        "signerRole": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "textbox1",\r\n                "name": "textbox1",\r\n                "fieldType": "TextBox",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 100,\r\n                  "y": 100,\r\n                  "width": 125,\r\n                  "height": 25\r\n                   },\r\n      "isRequired": true,\r\n    "validationType":"EmailAddress"\r\n  }\r\n  ],\r\n  "locale": "EN"\r\n}');

data.append('Files', fs.createReadStream('{you file path}'));

data.append('Title', 'Node JS validation');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'X-API-KEY': '{your api key}', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


Adding Currency Validation to Textbox field using API

The following sample code snippet demonstrates how to add Currency validation to a textbox field:

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Message={your message}' \
  -F 'Signers={
    "name": "starvritsa",
    "emailAddress": "starvritsabuhungi@boldsign.dev",
    "privateMessage": "sign",
    "authenticationType": "None",
    "deliveryMode": "Email",
    "signerType": "Signer", 
 
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "Textbox",
            "pageNumber": 1,
            "bounds": {
                "x": 140,
                "y": 140,
                "width": 82,
                "height": 32
            },
            "isRequired": true,
            "validationType": "Currency"
        }
    ]
}' \
  -F 'Files=@{Your file path};type=application/pdf' \
  -F 'Title={Document title}' \

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);
 
var documentFilePath = new DocumentFilePath
{
   ContentType = "application/pdf",
   FilePath = "{file path}",
};
 
var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};
 
var signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type: Type.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50),
    validationType: "Currency");

var formFieldCollections = new List<FormField>()
{
    signatureField
};
 
var signer = new DocumentSigner(
  signerName: "David",
  signerType: SignerType.Signer,
  signerEmail: "starvritsabuhungi@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);
 
var documentSigners = new List<DocumentSigner>()
{
    signer
};
 
var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Signers = documentSigners,
   Files = filesToUpload,
 
};
var documentCreated = documentClient.SendDocument(sendForSign);

import requests
import json
 
url = "https://api.boldsign.com/v1/document/send"
 
signer_data = {
    "name": "hanky",
    "emailAddress": "starvritsabuhungi@boldsign.dev.com",
    "signerType": "Signer",
    "signerRole": "Signer",
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "TextBox",
            "pageNumber": 1,
            "bounds": {
                "x": 100,
                "y": 100,
                "width": 200,
                "height": 200
            },
            "isRequired": True,
            "validationType":"Currency"
        }
    ],
    "locale": "EN"
}
 
payload = {
    'Signers': json.dumps(signer_data),
    'Title': "Agreement",
}
 
files = [
     ('Files', ('{file name}', open('{file path}', 'rb'), 'application/pdf'))
]
 
headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}
 
response = requests.post(url, headers=headers, data=payload, files=files)
 
print(response.text)

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

let data = new FormData();

data.append('Signers', '{\r\n        "name": "starvritsa",\r\n        "emailAddress": "starvritsabuhungi@syncfusion.com",\r\n        "signerType": "Signer", \r\n        "signerRole": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "textbox1",\r\n                "name": "textbox1",\r\n                "fieldType": "TextBox",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 100,\r\n                  "y": 100,\r\n                  "width": 125,\r\n                  "height": 25\r\n                   },\r\n      "isRequired": true,\r\n    "validationType":"Currency"\r\n  }\r\n  ],\r\n  "locale": "EN"\r\n}');

data.append('Files', fs.createReadStream('{you file path}'));

data.append('Title', 'Node JS validation');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'X-API-KEY': '{your api key}', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


Adding Regex Validation to Textbox field using API

The following sample code snippet demonstrates how to add numbers only Regex validation to a textbox field:

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Message={your message}' \
  -F 'Signers={
    "name": "starvritsa",
    "emailAddress": "starvritsabuhungi@boldsign.dev",
    "privateMessage": "sign",
    "authenticationType": "None",
    "deliveryMode": "Email",
    "signerType": "Signer", 
 
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "Textbox",
            "pageNumber": 1,
            "bounds": {
                "x": 140,
                "y": 140,
                "width": 82,
                "height": 32
            },
            "isRequired": true,
            "validationType": "CustomRegex",
            "validationCustomRegex": "^\\d+$",
            "validationCustomRegexMessage": "Enter numbers only"
        }
    ]
}' \
  -F 'Files=@{Your file path};type=application/pdf' \
  -F 'Title={Document title}' \

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);
 
var documentFilePath = new DocumentFilePath
{
   ContentType = "application/pdf",
   FilePath = "{file path}",
};
 
var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};
 
var signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type: Type.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50),
    validationType: "CustomRegex",
    validationCustomRegex: "^\\d+$",
    validationCustomRegexMessage: "Enter numbers only");

var formFieldCollections = new List<FormField>()
{
    signatureField
};
 
var signer = new DocumentSigner(
  signerName: "David",
  signerType: SignerType.Signer,
  signerEmail: "starvritsabuhungi@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);
 
var documentSigners = new List<DocumentSigner>()
{
    signer
};
 
var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Signers = documentSigners,
   Files = filesToUpload,
 
};
var documentCreated = documentClient.SendDocument(sendForSign);

import requests
import json
 
url = "https://api.boldsign.com/v1/document/send"
 
signer_data = {
    "name": "hanky",
    "emailAddress": "starvritsabuhungi@boldsign.dev.com",
    "signerType": "Signer",
    "signerRole": "Signer",
    "formFields": [
        {
            "id": "textbox1",
            "name": "textbox1",
            "fieldType": "TextBox",
            "pageNumber": 1,
            "bounds": {
                "x": 100,
                "y": 100,
                "width": 200,
                "height": 200
            },
            "isRequired": True,
            "validationType":"CustomRegex",
            "validationCustomRegex":"^\\d+$",
            "validationCustomRegexMessage":"Enter numbers only"
        }
    ],
    "locale": "EN"
}
 
payload = {
    'Signers': json.dumps(signer_data),
    'Title': "Agreement",
}
 
files = [
     ('Files', ('{file name}', open('{file path}', 'rb'), 'application/pdf'))
]
 
headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}
 
response = requests.post(url, headers=headers, data=payload, files=files)
 
print(response.text)

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
 
let data = new FormData();
 
data.append('Signers', '{\r\n        "name": "starvritsa",\r\n        "emailAddress": "starvritsabuhungi@syncfusion.com",\r\n        "signerType": "Signer", \r\n        "signerRole": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "textbox1",\r\n                "name": "textbox1",\r\n                "fieldType": "TextBox",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 100,\r\n                  "y": 100,\r\n                  "width": 125,\r\n                  "height": 25\r\n                   },\r\n      "isRequired": true,\r\n    "validationType":"CustomRegex",\r\n  "validationCustomRegex":"^\\d+$",\r\n  "validationCustomRegexMessage":"Enter numbers only"\r\n  }\r\n  ],\r\n  "locale": "EN"\r\n}');
 
data.append('Files', fs.createReadStream('{you file path}'));
 
data.append('Title', 'Node JS validation');
 
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'X-API-KEY': '{your api key}', 
    ...data.getHeaders()
  },
  data : data
};
 
axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});