ASP.net MVC and querySelectorAll.forEach

T.Zacks 3,986 Reputation points
2022-08-06T12:52:23.297+00:00

What is the meaning of this line onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",

using (Html.BeginForm("Login", "Default", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post,  
new  
{  
	id = "idMyForm",  
	onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",  
	@class = "form-signin",  
	role = "form"  
}))  
{  
  
}  

Thanks

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,158 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,253 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,601 Reputation points
    2022-08-06T17:22:24.86+00:00

    On the rendered form element, JavaScript is declared for the onsubmit attribute. This JavaScript finds all button elements that are a child of the form and disables them. Probably to prevent clicking a second time during the form post. Another common approach is is modal that displays a message.

    1 person found this answer helpful.
    0 comments No comments