Closed Ogglas closed 10 months ago
@Ogglas thanks for contacting us.
EditForm is a component, not an HTML element. We don't expose the underlying HTML form element anywhere, however, you can give it a name by passing the name
attribute and then change your JS code to do document.forms['myForm']
.checkValidity()
It's not clear to me what you are trying to accomplish, but I would definitely go the way the ObjectGraphDataAnnotationsValidator
than trying to use the checkValidity
API. That won't work with any Blazor/C# validation logic, it will only work with HTML5 built-in validation logic.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
@javiercn Thanks for your response! Solved it with HTML id attribute for now and will check out ObjectGraphDataAnnotationsValidator
later.
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I'm trying to use HTMLSelectElement:
checkValidity()
for a Blazor EditFormhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/checkValidity
The reason for doing this is that a Required field is set based on non top-level properties and user input and therefore
editContext.Validate();
does not work. I could perhaps use the experimentalObjectGraphDataAnnotationsValidator
but since the form knows if it is valid or not this is good enough for me.Describe the solution you'd like
In a normal html
form
I can validate it like this:Index.cshtml:
However using a
EditForm
causes the following exception if I try to assignref
to aElementReference
:If I use
EditForm
like this:I get this exception:
I could refactor JS to get HTML Id of the component but I think it should be possible to get
ElementReference
for aEditForm
?Additional context
No response