I have form input fields as type=number with readonly attributes. If I add min or max validations, these validations don't work in the server connect form unless readonly attributes are removed.
The server-side validations also don't trigger with readonly attribute when submited values are outside the min and max values.
Is it an expected behaviour? If it is, then how can I validate min or max values in the UI for input fields with readonly attribute?
Readonly inputs are not validated, this is by design:
If the readonly attribute is specified on an input element, because the user can not edit the input, the element does not participate in constraint validation.
@Teodor sorry, too early here, we need a sorry reaction haha
@guptast what about a hidden input linked to that? I'm pretty sure the validation message can be placed somewhere else (I'm sure I have done that before)
I am showing user a calculated value based on the input values in other fields. I need to add readonly attribute to the calculated field so that users can't change it's value before submitting the form.
Yes, I'm saying to apply the validation on the hidden input (the dynamic attribute value of the hidden input is the read only one)
So you're applying the validation there.
The only issue is that the validation message error can be also hidden, which means you need to make a workaround to show it