Computed field value

Hi guys,

Simple question…

I have a computed field on a form.

I also have a submit button on the same form. I want to add validation to this computed field so that i make sure that the field is not blank.

I understand that you declare a editable field like this:

var FirstName = form.FirstName.value;

And a drop-down field like this:

var Region = form.Region.options[form.Region.selectedIndex].text;

How do you declare a Computed Field??

Thanks.

Subject: Computed field value

You cannot check the value of a computed field in javascript, since the field is not known on the form. (you can put the value in a variable, but that is calculated when you open the form only).

So you’ll have to translate the logic of the computed field value to javascript.

Eg: if the formula in the computed field is

@if(fieldName=“”;“”;“OK”)

and you don’t want it to be blank, the javascript could be

if (form.fieldName.value == ‘’) {

alert(‘Field cannot be blank’);

}

Subject: RE: Computed field value

Hi Rene, sorry i do not understand what you are trying to suggest. Apologies.

Subject: RE: Computed field value

Is it possible to create an Editbale field that reads the value of the computed field?

Subject: RE: Computed field value

As far as the web browser is concerned, there is no computed field, just text. The only way for you to get that value would be to wrap your field inside of an html tag like

and then read the innerHTML of that tag.

Subject: RE: Computed field value

That’s like trying to eat soup with a fork: it is possible, but it is a hell of a job. And why not use a spoon if it is available?

What exactly is the formula in your computed field? What does it check?

Subject: Computed field value

First, how can it be possible for a computed field to fail validation? If you are setting the value, it either has the value you want or you have screwed up somehow. That is absolutely NOT the user’s fault, and there is not a thing on earth a user can do about it anyway, so you cannot block a user action because of it.

It may well be the case that you are computing the value based on some other user inputs, but guess what – computed fields compute at the server, not in the browser, so you need to allow the user to submit before you can check the computed value. You can check the editable values that you are basing your computed values on, though.