title: Javascript alternative to the HTML "required" function?
body: <p>So the <code>required</code> function on a html form works correctly in major web browsers, but it doesn't work with safari or on mobile devices. Is there a way to make users input text before proceeding using Javascript?</p>
  
  <p>Here's my javascript code (making limited characters);</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  function limitText(limitField, limitCount, limitNum) {
      if (limitField.value.length &gt; limitNum) {
          limitField.value = limitField.value.substring(0, limitNum);
      } else {
          limitCount.value = limitNum - limitField.value.length;
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and here's the html form input I wish to apply the required function too;</p>
  
  <pre><code>&lt;p id="username-field"&gt;
      &lt;label for="username"&gt;Username:&lt;/label&gt;        
      &lt;input name="username" type="text" id="username" onKeyDown="limitText(this.form.limitedtextfield,this.form.countdown,15);" 
  onKeyUp="limitText(this.form.limitedtextfield,this.form.countdown,15);" maxlength="15"&gt;        
      &lt;a href="https://minecraft.net/retrievename"&gt;Forgot username?&lt;/a&gt;
  &lt;/p&gt;
  &lt;p id="password-field"&gt;
      &lt;label for="password"&gt;Password:&lt;/label&gt;
      &lt;input tabindex="2" type="password" name="password" id="password" value="" onKeyDown="limitText(this.form.limitedtextfield,this.form.countdown,15);" 
  onKeyUp="limitText(this.form.limitedtextfield,this.form.countdown,15);" maxlength="15" required /&gt;
      &lt;a href="https://minecraft.net/resetpassword"&gt;Forgot password?&lt;/a&gt;
  &lt;/p&gt;
  &lt;p id="remember-field"&gt;
      &lt;input type="checkbox" name="remember" id="remember" value="true"  /&gt;
      &lt;label for="remember"&gt;Remember me&lt;/label&gt;
  &lt;/p&gt;
  &lt;p&gt;Clicking Submit will direct you to a page where you can see the information given.&lt;/p&gt;
  
  &lt;!--&lt;a href="#" target=""&gt;&lt;p&gt;Don't want to enter anything at all? Click this line to view a GIF of the procedure!&lt;/p&gt;&lt;/a&gt;--&gt;
  
  &lt;p class="middle"&gt;Or&lt;/p&gt;
  &lt;a href="done.php"&gt;&lt;p&gt;Visit the page containing already made fake-accounts displaying login information.&lt;/p&gt;&lt;/a&gt;
  &lt;p id="signin-field"&gt;
      &lt;input type="submit" name="submit" id="submit" value="Login" /&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>