How to use numbers with scientific notation?

The Number component does not support exponential notation (like "2.1e5"). As a workaround a TextField with custom validation can be used.

The following snippets show how to use JavaScript's Number and isNaN functions to validate the numeric input in the TextField.

guiInit

number = component.TextField("number", form);

validation          = componentProperties.Validate(number);
validation.custom   = "valid = isNaN(Number(input)) ? 'Not a valid number.' : true;";
number = component.TextField("number", form)

validation = component_properties.Validate(number)
validation.custom = "valid = isNaN(Number(input)) ? 'Not a valid number.' : true;"

Note that the validation does not convert the string to a numeric value. Hence, the value in the submission data must be converted before it can be used.

guiEvent

number = utils.getSubmissionData(payload, "number");
number = str2double(number);
number = utils.getSubmissionData(payload, "number")[0]
number = float(number)