Client Scripts: clearing currency field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2020 02:35 PM
We have anonChange client script that does a bunch of checks on a currency field (i.e. can't be above $5,000, needs to be multiples of $25, etc.) For each of these, if a user puts in a number that triggers one of those checks, we throw up an error message and we want to clear the field.
Below is a snippet of our code:
The issue we're running into is clearing the currency field. We tried clearValue (above), which does absolutely nothing. In other community posts, we've also tried the following:
g_form.setValue('u_award_cash_amount', 'NULL');
g_form.setValue('u_award_cash_amount', '0.00');
Both work in setting the value back to 0.00, however afterwards, it doesn't let the user edit the amount. It basically remains 0.00 until you refresh the page and start over. We've looked everywhere and cannot find anything on clearing a currency field; is this even possible?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 07:13 AM
Can you try?
g_form.setValue('u_award_cash_amount', '');
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 07:34 AM
thanks Prateek, I tried that before and it doesn't clear the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 08:19 AM
I think your logic goes through an infinite loop, when you are setting the value. Please update the if condition to
if((amt<50.00)&&(amt!=0.00||amt !='') )
and use
g_form.setValue('u_award_cash_amount', 'NULL');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 08:38 AM
Hi, just tried that and it sets the value to 0, but then you cannot type in another currency amount afterwards. thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2020 08:50 AM
Have you included the extra condition in 'if' logic? Its working fine for me.