You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I revisited an old MVC concept and started updating some of the components to .Net 9. I started updating my JavaScript client validation code and ran into a problem with the RangeAttribute.
The new RangeAttribute now supports MinimumIsExclusive and MaximumIsExclusive parameters.
[Range(1,10)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 and 10." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = true, MaximumIsExclusive = false)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 exclusive and 10." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = false, MaximumIsExclusive = true)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 and 10 exclusive." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = false, MaximumIsExclusive = true)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 exclusive and 10 exclusive." data-val-range-max="10" data-val-range-min="1"
Note the default error messages correctly reflects the intension. The actual server sider validation works as expected.
Historically for client validation one would retrieve a data attribute from an input element to do client validation with. A data attribute indicating the exclusive state of the minimum and/or maximum value(s) is absent in the generated HTML element. Except for the error message there is no other way one can determine the exclusive state of the value
The text was updated successfully, but these errors were encountered:
Recently I revisited an old MVC concept and started updating some of the components to .Net 9. I started updating my JavaScript client validation code and ran into a problem with the RangeAttribute.
The new RangeAttribute now supports MinimumIsExclusive and MaximumIsExclusive parameters.
[Range(1,10)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 and 10." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = true, MaximumIsExclusive = false)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 exclusive and 10." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = false, MaximumIsExclusive = true)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 and 10 exclusive." data-val-range-max="10" data-val-range-min="1"
[Range(1,10,MinimumIsExclusive = false, MaximumIsExclusive = true)] renders HTML attributes
data-val="true" data-val-range="The field Test must be between 1 exclusive and 10 exclusive." data-val-range-max="10" data-val-range-min="1"
Note the default error messages correctly reflects the intension. The actual server sider validation works as expected.
Historically for client validation one would retrieve a data attribute from an input element to do client validation with. A data attribute indicating the exclusive state of the minimum and/or maximum value(s) is absent in the generated HTML element. Except for the error message there is no other way one can determine the exclusive state of the value
The text was updated successfully, but these errors were encountered: