Skip to main content
Inspiring
September 3, 2021
Answered

Custom validation that won't give invalid value error

  • September 3, 2021
  • 2 replies
  • 3588 views

Hi all,

I need some help. I have a form that has a field (Total Funding Request) that can be filled in by someone entering a value or a sum of 3 other fields (Year 1 Multi Funding, Year 2 Multi Funding and Year 3 Multi Funding).

 

On those 3 fields I have under ‘Validate’ the 'Field value range' set, From:25000 To: 0 (as I want the numbers entered to be equal to or greater than 25,000 – not less –  and up to any number – that is why I set 0).

 

I have the ‘Total Funding Request’ field to ‘Calculate’ – ‘Value is the – ‘Sum (+)’ and I have picked the 3 fields (Year 1 Multi Funding, Year 2 Multi Funding and Year 3 Multi Funding). I also have under 'Validate' ‘Field value is in range’ set, From:25000 To: 0 (as I want the number entered to be equal to or greater than 25,000 – not less –  and up to any number – that is why I set 0).

 

The problem I am having is with (I think) the ‘Field value range’ on the ‘Total Funding Request’. If I put numbers in the three multi-year funding fields (and as long as they are over the 25,000 value) I get no warning. However, if I bypass the multi-year fields and go straight to the ‘Total Funding Request’ and put in a value, even if it’s over 25,000, I get a message that pops up that says: Invalid value: must be greater than or equal to 25,000. If I take the validation off I no longer get the error but I need it there if someone doesn’t choose the multi-funding option and goes straight to the ‘Total Funding Request’.

 

Is there some kind of script that can allow someone to put a value in to the ‘Total Funding Request’, restrict the value to be equal to or greater than 25,000 and won’t give me the warning that the value must be greater than 25,000?

 

Thanks

This topic has been closed for replies.
Correct answer Nesa Nurani

Thanks Try67,

I took that line out and I no longer get the warning but basically if someone puts a value that is under 25,000 it just doesn't allow that number to go in.

 

Is there no way to have the warning come up for values below 25,000 but no warning to come up for values equal to or greater than 25,000? Your orginal script had the warning come up in both senerios and now it doesn't come up at all leaving the person to wonder why it won't take their number (eventhough they should know that the application is for greater than 25,000).

 

Thanks again for helping me out.


If you set 'Field value is in range:' as you originaly intended, you can use this as 'custom calculation script' of "Total Funding Request" field:

 

var a = Number(this.getField("Year 1 Multi Funding").value);
var b = Number(this.getField("Year 2 Multi Funding").value);
var c = Number(this.getField("Year 3 Multi Funding").value);
if(a==0 && b==0 && c==0)
event.rc = false;
else
event.value = a+b+c;

 

2 replies

try67
Community Expert
September 3, 2021

You can use this code as the field's custom validation script:

 

if (event.value && Number(event.value)<25000) {
	app.alert("The value must be 25,000 or more.");
	event.rc = false;
}
Inspiring
September 7, 2021

Thanks Try67,

I did put this script in but as Asim123 mentioned I still got the warning alert. Is there a custom script I would need in the Calculate tab to make this work?

Inspiring
September 8, 2021

If you set 'Field value is in range:' as you originaly intended, you can use this as 'custom calculation script' of "Total Funding Request" field:

 

var a = Number(this.getField("Year 1 Multi Funding").value);
var b = Number(this.getField("Year 2 Multi Funding").value);
var c = Number(this.getField("Year 3 Multi Funding").value);
if(a==0 && b==0 && c==0)
event.rc = false;
else
event.value = a+b+c;

 


Thank you very much Nesa the script worked like a charm.

Bernd Alheit
Community Expert
September 3, 2021

This is possible with a custom validation script.