Skip to content
Advertisement

Button onsubmit() event is not working on react

I tried to coding the form submission code on ReactJS and Express,NodeJS but I got some problem with the onSubmit() event

Everytime that I code <form onSubmit={loginUser}> the button won’t submit, can’t even click. But if I remove to <form>, the button can click normally

I changed in to <input type='submit'>Login</input> and the page has gone blank

Here’s the code

JavaScript

I tried to changed to <form onSubmit = {this.handleSubmit}> but the button still can’t click

Advertisement

Answer

This could be a scope problem because you have the button inside of a div

try this

JavaScript

That should call the function directly when you click the button

However, it works fine on sandbox without this edit and no css https://codesandbox.io/s/wonderful-wiles-fv9vet?file=/src/App.js

it is most likely that pointer-events is set to none on the button somewhere, try setting this css property

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement