Hello
I want to extend the number type, so that the user may specify if the entered number may have decimal places and if yes how many decimals places may be entered.
I know that it's possible to define that by using regex expressions, but I would like to spare my users from that.
So I managed to let the user enter the maximal allowed decimal places.
By entering 0 that would mean that only integer values may be entered.
And if he enters for example 2 that would mean that only numbers with maximal 2 decimal places may be entered.
I managed to create and display the property in the creator:
JavaScriptSurvey.Serializer.addProperty("text", {
name: "decimals",
type: "number",
displayName: "Dezimalstellen",
isRequired: false,
category: "general",
minValue: 0,
visibleIndex: 9,
dependsOn: ["inputType"],
visibleIf: function (obj) {
return (
obj.inputType === "number"
);
}
});
But now I did not find any post/documentation, that shows me how I could validate the number entered in the form to satisfy this condition if this property is set.
Can you help me?
Could one solution be to generate and set the corresponding regex expression as validator when this property is set/changed resp. remove the regex validation if the value is deleted?
Perhaps it would be simpler to just validate the entered value if decimal places are set and show a corresponding error message if the entered value does not match the setting?