Is there a way to set the currency default value to blank instead of 0.00?

jerryzheng
Tera Contributor

Hi Expert,

  Is there a way to set the currency field default value to blank instead of 0.00 because we set the field to be mandatory to force users to enter amount > 0?

Thanks for your help!

 

Jerry

2 REPLIES 2

Mark Stanger
Giga Sage

You can't make a currency field mandatory directly and you can't set an empty default value.  You can do a couple of things though...

1)  Change the field to a decimal field where you can make it mandatory and empty by default.

or...

2)  Use an 'onSubmit' client script to perform the mandatory validation.  I think this is the best option.  Here's a client script you could use.  Just replace 'u_amount' with the name of your currency field...

function onSubmit() {
	// Make sure 'Amount' is not zero
	if (parseFloat(g_form.getValue('u_amount').split(';')[1]) <= 0) {
		g_form.addErrorMessage("Please enter an amount greater than zero in the 'Amount' field.");
		g_form.setMandatory('u_amount', true);
		return false;
	}
}

Please mark this as the correct answer if I've answered your question.  Thanks!

Sandeep Reddy L
Tera Contributor

Hi Jerry,

You can't make currency field value to blank. But there is a way to keep currency field value mandatory even though we have that default value 0.00 through onload client script. The below script may help you:

function onLoad() {
var empty = 0;
var emptyfixedto = empty.toFixed();
if (g_form.isNewRecord()) {
g_form.setValue('u_currency_field ',emptyfixedto);

}
}

and while creating currency filed make sure to check mandatory.

 

Regards,

Sandeep Reddy Lebaka.