How to set character limit for textbox form fields using BoldSign API?
In BoldSign, the fixed width option in TextBox
form field allows you to set character limits for the form field during the document creation process. This feature is essential for ensuring that the input provided by signers meets specific length requirements.
Setting these limits helps guide signers on the expected length of input, which is particularly useful in scenarios requiring a specific format or length, such as phone numbers, zip codes, or credit card numbers.
Setting fixed width option in TextBox field
You can set a character limit in the BoldSign API using the characterLimit
option by specifying the maximum number of characters a user can input in the field. You can adjust the character limit according to your needs and preferences, either increasing or decreasing the limit as required.
If you set the character limit to 10 in a textbox field, the signer will be restricted to inputting a maximum of 10 characters. This ensures that the input adheres to the specified limit, preventing any deviations from the required format.
Use the following codes to set character limit in textbox field:
Code snippet
curl -X 'POST' \ 'https://api.boldsign.com/v1/document/send' \ -H 'accept: application/json' \ -H 'X-API-KEY: {your API key}' \ -H 'Content-Type: multipart/form-data' \ -F 'Title="Sample Document"' \ -F 'Signers={ "name": "hanky", "emailAddress": "starvritsabuhungi@boldsign.dev", "signerType": "Signer", "formFields": [ { "id": "TextBox", "name": "TextBox", "fieldType": "TextBox", "pageNumber": 1, "bounds": { "x": 100, "y": 100, "width": 125, "height": 25 }, "isRequired": true, "characterLimit": 10 } ], "locale": "EN" }' \ -F 'Files=@{your file};type=application/pdf' \
var apiClient = new ApiClient("https://api.boldsign.com", "{Your API key}"); var documentClient = new DocumentClient(apiClient); var documentFilePath = new DocumentFilePath { ContentType = "application/pdf", FilePath = "{Your File path}" }; var filesToUpload = new List<IDocumentFile> { documentFilePath, }; var TextBoxField = new FormField( id: "TextBox", isRequired: true, type: FieldType.TextBox, pageNumber: 1, bounds: new Rectangle(x: 100, y: 100, width: 125, height: 25), characterLimit: 10); var formFieldCollections = new List<FormField>() { TextBoxField }; var signer = new DocumentSigner( name: "David", emailAddress: "starvritsa@boldsign.dev", formFields: formFieldCollections, locale: Locales.EN); var documentSigners = new List<DocumentSigner>() { signer }; var sendForSign = new SendForSign() { DisableEmails = true, Signers = documentSigners, Files = filesToUpload, Title = "Sample Document" }; var documentCreated = documentClient.SendDocument(sendForSign); Console.WriteLine(documentCreated.DocumentId);
import requests import json url = "https://api.boldsign.com/v1/document/send" signer_data = { "name": "hanky", "emailAddress": "starvritsa@boldsign.dev", "signerType": "Signer", "signerRole": "Signer", "formFields": [ { "id": "TextBox", "name": "TextBox", "fieldType": "TextBox", "pageNumber": 1, "bounds": { "x": 100, "y": 100, "width": 125, "height": 25 }, "isRequired": True, "characterLimit": 10 } ], "locale": "EN" } payload = { 'Signers': json.dumps(signer_data), 'Title': "Sample Document" } files = [ ('Files', ('{Your file name}', open('{Your 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', JSON.stringify({ "name": "hanky", "emailAddress": "hankyWhites@gmail.com", "signerType": "Signer", "signerRole": "Signer", "formFields": [ { "id": "TextBox", "name": "TextBox", "fieldType": "TextBox", "pageNumber": 1, "bounds": { "x": 100, "y": 100, "width": 125, "height": 25 }, "characterLimit": 10, "isRequired": true } ], "locale": "EN" })); data.append('Files', fs.createReadStream('{Your file path}')); data.append('Title', "Sample Document"); 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); });
In the provided code example, replace characterLimit
with the maximum number of characters that a user can input into a specific form field. Upon executing the provided code, a document will be generated with the specified character limit value for the textbox field.