Hidden Form field validation

I have a hidden form field that is required. I cannot get the error message to show up. Even if i trigger a validation it will not show. If I change from hidden to text it works fine. How can I get the error message to show when it is hidden?

input type=“hidden” name=“userid” id=“inp_userid” required="" data-msg-required=“Select User First”
div class="" id=“hidden_error” dmx-show=“inp_userid.invalid”
Select User First
/div

Hi, why would you have the field hidden when it’s required? How is the user supposed to enter data in it?