I am facing a seemingly simple issue, but I lack experience with scripts:
In my _Layout.cshtml file, I have the following Script:
<script>
$('button').click(function () {
$(this).prop('disabled', true);
});
</script>
One of my views contains the following code:
@using (Html.BeginForm("Create", "Home", FormMethod.Post, null))
{
@Html.AntiForgeryToken()
<div class="mt-5 d-flex flex-row">
<textarea class="form-control" name="TextArea"></textarea>
<button class="btn btn-secondary btn-block mt-2 post-btn" type="submit" id="PostButton">Post</button>
</div>
}
This form functions correctly without the script, but for some reason, it does not work with the script active.
I placed the script in the _layout.cshtml file because I want it to apply to all buttons on my asp.net page.
After clicking on the button, it gets disabled as intended, but the "Create" action result in the HomeController is not being called.
I believe I need to modify the script. Can someone provide me with guidance on how to do so?
Thank you all