javascript - the labels flashes instead of being displayed -


as shown above it's register form , every field not filled ... label shown when submitting ... , it's working fine ! added code generator ... when user entered wrong code(mismatch) submit form ... there alert. when call in javascript whole javascript code not working ... label flashing instead of displaying next fields

function registerform(){       var allow=true;   var tit=document.signup.title.value;        if(tit ==""){     document.getelementbyid("title_error").style.display="inline";      allow= false;  }    else{     document.getelementbyid("fname_error").style.display="none";  }   var key=document.comp.gen.value;   var key1=document.comp.matched.value;     if (key !=key1){    alert(" code didn`t match");     allow=false;  }              return allow;  }
<html>  <body>  <?php  function generaterandomstring($length=10) {      $characters = '0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';      $characterslength = strlen($characters);      $randomstring = '';      ($i = 0; $i < $length; $i++) {          $randomstring .= $characters[rand(0, $characterslength - 1)];      }      return $randomstring;  }      ?>  <form method="get"  name="signup" onsubmit="return registerform()">   <h1 id="head"></head></br>  <h1 >user registration</h1>   <h4 id="req">*donates required fields</h4>  <table>     <tr>    <td>title:*</td>    <td><input type="text" name="title"/></td>    <td><label style="color:red; display:none;" id="title_error">enter title</label>    </td>   </tr>     <tr>    <td>first name:*</td>    <td><input type="text" name="fname"/></td>    <td><label style="color:red; display:none;" id="fname_error">enter first name</label>    </td>   </tr>   <tr>    <td>type this:*</td>    <td><input type="text" name="matched"></td>    <td><input type="text" readonly name="gen"value="<?php echo generaterandomstring(); ?></td>   </tr>   <tr>    <td><input type="submit" class="btn" value="register"></td></tr>  </form>  </table>  </body>  </html>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -