5.20203.748
5.20203.748

Using the min and max properties

Several Wijmo controls have min and max properties that can be used to restrict values entered by users. Wijmo controls with min and max properties include Gauge, Calendar, InputDate, InputNumber, and InputNumber.

The behavior of the min and max properties is the same for all controls: if specified (they may be set to null), the control will apply them as constraints on the value of the value property. Users will not be able to change the control value to anything smaller than min or larger than max.

This behavior is different from the min attribute of standard HTML input elements, which does allow users to enter invalid values and raise validation errors. The Wijmo controls simply prevent invalid values from being entered at all.

However, note that the min and max properties only restrict the values that the user can enter. They do not restrict the values that can be assigned to the control in code or via bindings.

Therefore, if your code sets or changes the value of the min and max properties, and you want these limits to be applied to the current control value, you must do that in code as well.

For example:

// 'ctl' is any Wijmo control with min/max properties, including
// Gauge, Calendar, InputDate, InputNumber, and InputNumber.

// apply new bounds for the value
ctl.min = newMinValue;
ctl.max = newMaxValue;

// ensure that the control value is within the new bounds
ctl.value = wijmo.clamp(ctl.value, ctl.min, ctl.max);