0

i remove input submit id (id="signup") code is working properly but add id (id="signup") submit function not working why ???

function signup() {

  alert("form and return false is working");
  return false;
}
<form onsubmit="return signup()">
  <input type="text">
  <input type="submit" value="submit" id="signup">
</form>
Jeremy Thille
  • 26,047
  • 12
  • 43
  • 63
sudhir
  • 21
  • 3

2 Answers2

0

its very strange but maybe cause id is unique and in your code it's declared two times. one time for input and other time for function name. try change function name or id name to something else then its work.

0

You are defining the function and the ID with the same string and that must be why your program is failing. Simply rename either the function or the id like so:

function signup() {

  alert("form and return false is working");
  return false;
}
<form onsubmit="return signup()">
  <input type="text">
  <input type="submit" value="submit" id="submitSignup">
</form>
Antfere
  • 90
  • 6