html - Password Validation in JavaScript Error -


i having trouble simple password validations.

these things validation does

  • check if password less 8 characters
  • check if more 15 characters
  • check if new password , retyped mismatched

the form submits when 2 passwords matched if less or greater validations

please see code:

function on_submit(dest) {      var objform = document.logonform;     var strmissinginfo = "";      if (dest == 'logon') {          if (objform.current.value != "") {              if (objform.new1.value.length < 8 || objform.new1.value.length > 15) {                 strmissinginfo += "\n   password must 8 15 characters long";              } else if (objform.retype.value != objform.new1.value) {                 strmissinginfo += "\n   password mismatch!";              }              if (strmissinginfo != "") {                 alert(strmissinginfo);              } else {                 alert(strmissinginfo);                 objform.action.value = dest;                 objform.submit();             }         }     } } 

--- html part

<input type="password" id="current" name="current"                                 onkeypress="return isnumberkey(event)" style="width: 180px"                                 tabindex="1" required/>  <input type="password" id="new1" name="new1"                                 onkeypress="return isnumberkey(event)" style="width: 180px"                                 tabindex="2" required />  <input type="password" id="retype" name="retype"                                 onkeypress="return isnumberkey(event)" style="width: 180px"                                 tabindex="3" required />  <a href="javascript:;">                     <input id="logonbutton" class="submit"                         type="submit" name="submit" value="confirm" tabindex="4"                         onclick="on_submit('logon')" />                     </a> 

if want form fail on submission try returning false when validation fails.

        if (strmissinginfo != "") {             alert(strmissinginfo);             return false;         } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -