Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you've got the form syntax wrong - onsubmit = the name of the js function to call, action = the url...</p> <pre><code>&lt;form action="accountcode.php" id="newaccount" name="newaccount" method="post" onSubmit="return checknewaccount()"&gt; &lt;input type="text" id="email" onBlur="emailvalid()"/&gt; &lt;input type="text" id="username" onBlur="checkname()" /&gt; &lt;input type="password" id="password" onkeyup="passwordcheck()"/&gt; &lt;input type="submit" value="New"/&gt; &lt;/form&gt; </code></pre> <p>Fully tested code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function checknewaccount() { return emailvalid() &amp;&amp; checkname() &amp;&amp; passwordcheck(); } function emailvalid() { var emailAddress = document.getElementById('email').value; return (emailAddress=='test'); } function checkname() { return true; } function passwordcheck() { return true; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="#" onsubmit="return checknewaccount();"&gt; &lt;input type="text" id="email" name="email"/&gt; &lt;input type="submit"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The form in the above code will only submit if the textbox has a value of <strong>test</strong></p> <p>A slightly better implementation would be:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function checknewaccount() { if(emailvalid() &amp;&amp; checkname() &amp;&amp; passwordcheck()) { return true; } else { document.getElementById('validation').innerHTML = 'Validation failed!'; return false; } } function emailvalid() { var emailAddress = document.getElementById('email').value; return (emailAddress=='test'); } function checkname() { return true; } function passwordcheck() { return true; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="validation"&gt;&lt;/div&gt; &lt;form action="#" onsubmit="return checknewaccount();"&gt; &lt;input type="text" id="email" name="email"/&gt; &lt;input type="submit"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>As this at least tells the user the form wasn't submitted. Even better would be to give the user a more detailed reason why but that's beyond the scope of this question...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload