cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

I have a currency field.  If a user adds the "$" sign to the currency field along with the amount, the calculated field below does not calculate properly.  Is there a way to create a validation or some way, programmatically, to not accept the "$" sign?

Labels: (1)
0 Kudos
Reply
18 Replies
Highlighted
Nintex Newbie

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

There are a couple ways to do this.

 

1. You could use a validation rule on the text field:

contains({Self},"$")

2. Or, the validation could be set in the control's settings using regex:

2019-03-18_16-19-49.png

 

The problem with these two types of field validation is that they will not fire until the user submits the form. Once they do that, the form will display all errors for the form.

 

3. If you want the validation to be as soon as the user exits the field, you could use JavaScript.

 

I don't have the JavaScript code at the moment, but if you would like it, let me know and I'll whip something up. There are many options with it. You could fire the error message on each keypress or only when the exit the field. And then you have options for how you can display the error too.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

Hi Chad,

Thank you!  Yes, please, if you would be able to provide a javascript snippet that fires as soon as the field is exited, along with a pop up message explaining the error, I would be very appreciative! :)

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

if you'd like a non-javascript solution, you could update your formula like

 

1*replace(sourceControl,"\\$","")

so that it removes  $ sign and calculates  correctly regardless it's there or not

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

Hi Emha,

Thank you for replying.  I have a few questions.  Where are you placing this formula, in a rule, under formatting?  I am assuming that "sourceCode" in your example is a variable?  If so, why would you not use the "named" field?

 

I tried applying this formula under a rule, under formatting and it did not work.  Perhaps I do not understand where this formula should be applied?

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

yes, "sourceControl" is meant a named control that holds your currency value and that appears in your validation formula.

you should use my snippet in place of your "sourceControl" reference.

 

so if eg. your original validation formula looks like 

sourceControl < 100

it should now look like

1*replace(sourceControl,"\\$","") < 100

 

 

i.jpg

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

It is not behaving as expected.  See below.  Now the validation flags the field, regardless if there is a dollar sign or not.Picture1.png

 

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

1. validation error at the right-most picture doesn't seem to be caused by this rule. if it was there would be an error message just like on middle one

 

2. your validation formula doesn't seem to be correct. validation formula has to evaluate to boolean TRUE/FALSE. your formula evaluates to a number entered in ShipmentCost field. and anything but zero is regarded as TRUE, hence you always get validation error for a number different from zero.

 

 

 

if you want to have a validation formula which just check for presence of $ sign, you'd better use contain() runtime function.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

1. the validation error message was the same across, I just did not display it twice.  I disgaree, the error message is indeed being caused by the validation.

2. "if you want to have a validation formula which just check for presence of $ sign"  That is the question that I was asking.  The $ sign is interfering with the calculation of the "Total" field below.

 

I think I will wait for Chad to provide the javascript snippet.  Thank you for trying to help.

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: How do I validate a currency field not to have a dollar sign ($) ?

Jump to solution

then you should apply the same to the 'Total' calculation formula (and you do not need validation rule that check $ occurence)

 

eg.

1*replace(ShipmentCost,"\\$","") + 1*replace(TaxCost,"\\$","")

 

0 Kudos
Reply