Thanks for the update,
We were unable to reproduce the issue, “Button OnClick event is not work” by the given code. From our end, the given code is working perfectly and the OnClick event is also working for the sample. We have also provided the video demo for the corresponding sample.
Please find the video in the below link.
We have also attached the sample by setting the required field validation.
Please share the screenshots of the corresponding error , so that we will help you.