Client script for decimal points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 10:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2024 11:31 PM
Hello @User_267
Why can't you set formatted value back in the function itself like-.
function onChange(control, oldValue, newValue, isLoading) {
// Check if the form is still loading
if (isLoading || newValue === '') {
return;
}
// Format the input as a decimal with a dollar sign
var formattedValue = formatAsCurrency(newValue);
// Set the formatted value back to the field
g_form.setValue(control.name, formattedValue);
}
function formatAsCurrency(value) {
// Format the input as a decimal with a dollar sign
var decimalValue = parseFloat(value).toFixed(2);
var formattedValue = '$' + decimalValue;
return formattedValue;
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 12:28 AM
Hi @User_267
If you are using currency type variable, you need to set the value in the below format
var currency="USD"; //give the currency code whichever you want to append
var finalValue='12.00';
g_form.setValue('variableName',currency+';'finalValue);
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 01:21 AM
But when iam entering number also it is showing error. But when we enter number it shouldn't show error.how to do this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 01:26 AM
Hello @User_267 I did not get what you are saying.
Can you please provide screenshot or explain clearly.
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.