Skip to main content
Solved

Number field validation to only allow positive values

  • February 10, 2025
  • 3 replies
  • 32 views

Forum|alt.badge.img+1

I have a number field currently that accepts all values. I want to add a validation/condition that would restrict the field to only accept positive values (values >= 0) 

How do I do this?

Best answer by Pawan Gangwani

Hello ​@Radha 

Welcome to the DocuSign Community!

Currently you cannot apply the custom validation on the number type field in document generation. Now instead of the Number field, you can use the Text field and add the Customer regex validation which exactly full fill the requirement. Here is the Regex.

Regex: ^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$

Thank you, Hope it helps!

View Original
Is this content helpful?

3 replies

Pawan Gangwani
Rising Star
Forum|alt.badge.img+13
  • Rising Star
  • 407 replies
  • Answer
  • February 10, 2025

Hello ​@Radha 

Welcome to the DocuSign Community!

Currently you cannot apply the custom validation on the number type field in document generation. Now instead of the Number field, you can use the Text field and add the Customer regex validation which exactly full fill the requirement. Here is the Regex.

Regex: ^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$

Thank you, Hope it helps!


Forum|alt.badge.img+1
  • Author
  • Newcomer
  • 1 reply
  • February 10, 2025

Thank you for this solution, ​@Pawan Gangwani!

There is a slight problem here though. The number field is already referenced in multiple places, and I don’t think I should be changing it to a text field. Any workaround possible?


Pawan Gangwani
Rising Star
Forum|alt.badge.img+13
Radha wrote:

Thank you for this solution, ​@Pawan Gangwani!

There is a slight problem here though. The number field is already referenced in multiple places, and I don’t think I should be changing it to a text field. Any workaround possible?

Then the only workaround here is at the workflow level.

1. In the workflow identify the field having negative value using the c# code.
2. Conditionalize the workflow, to give user the option to validate the field again for example get the new Doc Gen in middle to rectify the filed. and there you can use the text field and put regex.

Thanks!