Answer the question
In order to leave comments, you need to log in
How did the page not move to the top when the form was validated?
The data entry form is located at the very bottom of the site. When checking the validity of the data in the model, it abruptly moves to the very top of the site, that is, the site is being updated. How can I make the visitor see the form after validating the entered data. Asp.Net Core MVC
Answer the question
In order to leave comments, you need to log in
Do not send data!
There is client validation, use it.
If it's not enough, use partial view, you can also load it through Ajax.
There are many options. In addition, you can make a client script to focus on the input field.
For example, on a postback, move focus to a field with an error
https://developer.mozilla.org/en-US/docs/Web/API/H...
If you just stupidly make a form, then when you click on a Submit type button, a POST request will occur with the corresponding page reload.
Several options are possible here. If validation can be safely done on the client, do it on the client by submitting the form programmatically. Or make an AJAX request.
In any case, instead of
specifying
Next, catch the click of this button and either submit the data via AJAX, or decide via client-side validation whether to submit the form or not.
<button type="submit".. >
<button type="button"..>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question