2017-05-04 62 views
0

點擊忘記鏈接電子郵件字段應該驗證使用JavaScript,我有一個完成的代碼任何錯誤,請告訴我,下面顯示的JavaScript代碼鏈接可能會衝突一次,建議我點擊忘記鏈接電子郵件字段應該驗證使用javascript

<form id="form1" name="form1" action="<?php echo base_url(); ?>Index.php/Login_cntrl/login" method="POST" > 
    <div class="field-wrap"> 
    <label class="view-label">Email Address</label> 
    <input type="email" placeholder="Email Address" name="email" id="email" class="input-control" value="<?php echo set_value('email'); ?>"/> 
    <span class="text-danger"><?php echo form_error('email'); ?></span> 
    </div> 
    <!--<div id='errorDiv' class='col-xs-12 pull-right'> </div>--> 
    <div class="field-wrap"> 
    <input type="password" placeholder="Password" name="password" id="password" value="<?php echo set_value('password'); ?>"/> 
    <span class="text-danger"><?php echo form_error('password'); ?></span> 
    <a href="javascript:void(0)" class="btn btn-link btn-nobg" id="btn-show-forgot" >Forgot ?</a> 
    </div> 
    <!--<div id='errorDivv' class='col-xs-12 pull-right'> </div>--> 
    <div class="field-wrap"> 
    <button type="submit" class="btn btn-submit" name="ulogin" id="ulogin" value="ulogin" >Login</button> 
    <?php 
     if (isset($message)) { 
     echo $message; 
     } 
    ?> 
    </div> 
    <div class="field-wrap"> 
    <a href="javascript:void(0)" class="btn btn-link btn-nobg" id="btn-show-signup">NEW User? Sign up</a> 
    </div> 
</form> 

的JavaScript

<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script> 
<script type="text/javascript" src="<?php echo base_url(); ?>js/testing.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script src="https://code.jquery.com/jquery-1.11.3.js"></script> 
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
<script src="https://code.jquery.com/jquery-2.1.4.js"></script> 
<!-- Did you omit follow library? --> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script> 
<script> 
    $(document).ready(function() { 
    $("#form1").validate({ 
     rules: { 
     email: "required" 
     }, 
     messages: { 
     email: "Please specify your name" 
     } 
    }) 
    $('#btn-show-forgot').on('click', function() { 
     $("#form1").valid(); 
    }); 
    }); 
</script> 

回答

0

它應該是:

<script> 
     $(document).ready(function() { 
      $("#form1").validate({ 
      rules: { 
       email: "required" 
      }, 
      messages: { 
       email: "Please specify your name" 
      }, 
      submitHandler: function(form){ 
       form.submit(); 
      } 
      });//validate() 
     }); 
     </script> 

submitHandler在窗體驗證成功時調用。所以,我們在這裏提交表單,一旦驗證成功。

+0

問題是遺忘的鏈接甚至沒有工作,可能是這麼多的JavaScript鏈接都是有用的建議我 –

相關問題