javascript - Posting to a separate document using <form> and POST -


my first post here @stackoverflow. please bear me.

look @ code below. want javascript post php (applybeta.php) document if there '@' in field name & id 'epost'. if there isn't '@' in field, messagebox pop telling user entered invalid e-mail address.

if don't enter '@' message box shows up. if enter valid email doesn't post "applybeta.php", nothing happens @ all. got idea why? sorry if description vague, you'll figure out mean :)

the e-post field got both id , name because tried both, none of them works.

<!doctype html> <html>     <head>         <title>binärklocka</title>         <meta charset="utf-8" />         <link rel="stylesheet" type="text/css" href="index.css">         <link href='http://fonts.googleapis.com/css?family=pt+mono' rel='stylesheet' type='text/css'>         <!-- table font --> <link href='http://fonts.googleapis.com/css?family=lato:900italic' rel='stylesheet' type='text/css'>     </head>     <body>         <script>         function kollaepost() {             var x = document.getelementbyid("email");              if(x.value.indexof('@') === -1) {                 alert("you didn't enter valid e-mail address!");             }             else {                 document.getelementbyid("minform");                 //z.submit();                 //alert("hej");             }          }         </script>         <div id="wrap">             <div id="main">                 <br>                 <br>                     <table id="nav">                           <tr>                             <td><a href="store.html">store</a></td>                             <td><a href="ourproducts.html">our products</a></td>                             <td><a href="index.html"><img src="home.png" alt="hem" width="60" height="60"/></a></td>                             <td><a href="aboutus.html">about us</a></td>                             <td><a href="contact.html">contact</a></td>                           </tr>                     </table>                  <hr id="linje1" />             </div>         </div>         <p id="binaryclock"  onclick="showlink()">             looking beta testers our newly created clock!<br />             participate, fill in forms below real name</br />             , valid e-mail address , download link appear.         </p>              <!-- form want post -->         <div id="applybeta">             <form action="apply.php" method="post" id="minform" name="minform">                 <input type="text" placeholder="full name" name="name" /><br />                 <!-- checking field '@' -->                  <input type="text" placeholder="e-mail" id="email" /><br /><br />                 <!-- end of field -->                 <input onclick="kollaepost()" type="button" name="submit" value="send" /><br />             </form>         </div>             <!-- end of form -->         <div id="dlink">             shdgfgh<a href="http://www.google.se">click here download</a>         </div>         <div id="bottomtext">             <p>@ 2015 clockmasters elite</p>         </div>     </body> </html> 

instead of having input of type button, try submit. onclick-function can serve validation function returning true or false, , influence whether form submitted. this:

<input onclick="return kollaepost()" type="submit" name="submit" value="send" /> 

and:

<script> function kollaepost() {     var x = document.getelementbyid("email");      if(x.value.indexof('@') === -1) {         alert("you didn't enter valid e-mail address!");         return false;     }     return true; } </script> 

also see this question more detailed explanation on method, in general.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -