I have this error > App.validate is not a function at HTMLInputElement.onclick
The code is here :
i get error in the last ( >) input type="submit" name="submit" onclick="App.validate()"
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Classic bug! You need to provide a function, rather than actually calling the function. The key here is
By adding the
() after validate, your code is instantly calling
validate when the page loads -- the return value of
App.validate() is what's actually being set as
onClick. If you change it to
then you'll be passing the function itself rather than its return value.
Edit: That said, you should double check that your function actually exists. Try adding a script tag which calls the function with some sample input and then logs it:
<script> console.log('App.validate: ',App.validate) console.log("App.validate('yourname')", App.validate('yourname')) </script>
If the first line prints out your function and the second line works correctly, then you ought to be good to go. If not, then the function doesn't exist where you think it does and now you know where to look next in your debugging process!