title: Prevent php from executing code after Javascript validation fails and prevent some characters with JS
body: <p>I have a user registration form and after the user has filled all informations I submit the entered values:</p>
  
  <pre><code>&lt;?php if (isset($_POST['submit'])) {
            echo '&lt;script type="text/javascript"&gt;CheckPassword(document.userform.password);&lt;/script&gt;';
  
          ## connect mysql server
              $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
              # check connection
              if ($mysqli-&gt;connect_errno) {
                  echo "&lt;p&gt;Fehler Nummer {$mysqli-&gt;connect_errno} : {$mysqli-&gt;connect_error}&lt;/p&gt;";
                  exit();
              }
          ## query database
              # prepare data for insertion
              $username   = $_POST['username'];
              $password   = $_POST['password'];
              $first_name = $_POST['first_name'];
              $last_name  = $_POST['last_name'];
              $email      = $_POST['email'];
  
              # check if username and email exist else insert
              // u = username, e = emai, ue = both username and email already exists
             //the rest of the code is not important for this question
  </code></pre>
  
  <p>On the first line (<code>echo '&lt;script...</code>) I call the following javascript function:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              function CheckPassword(inputtxt)   
              {   
                  var passw = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/;  
                  if(inputtxt.value.match(passw))   
                  {   
                      alert("check");
                      return true;  
                  }  
                  else{
                      alert("!check");
                      return false;
                  }
              }
          &lt;/script&gt;
  </code></pre>
  
  <p>The call works perfectly but if the user has entered an invalid password I do not want to run the rest of the php code. </p>
  
  <p>Further I would like to prevent the user to enter special characters, such as: ', ", `, ´,.. How can I do this in Javascript?</p>