2016-10-04 85 views
0

我试图在登录后在html上清空我的文本字段。我注销后,我插入的数据仍然存在。我怎么做?这是我的html,谢谢你的帮助。我点击提交按钮后如何刷新文本字段?

<div class="tabs-striped tabs-background-positive tabs-color-light"> 
    <div class="tabs"> 
     <a class="tab-item active" href="#/app/login"><i class="icon ion-unlocked"></i> Login</a> 
     <a class="tab-item" href="#/app/signup"> <i class="icon ion-person"></i> Sign Up </a> 
    </div> 
</div> 

<ion-view view-title="Sign In" class="loginBg" hide-nav-bar="true" > 

    <ion-content class="padding"> 

    <div class="row responsive-sm padding remvoeBP"> 
     <div class="col"> 
      <center><img src="img/logo.png" alt="Item Img" width="275" height="90"></center> 
      <br> 
      <div class="list list-inset"> 
       <label class="item item-input"> 
        <input type="text" id="phone" placeholder="Phone Number" ng-model="user.phone" ng-maxlength="13" onkeypress='return event.charCode>=48 && event.charCode<=57' required autocomplete="off"> 
       </label> 

       <label class="item item-input"> 
        <input type="password" id="pin" placeholder="PIN" ng-model="user.pin" ng-maxlength="6" onkeypress='return event.charCode>=48 && event.charCode<=57' required autocomplete="off"> 
       </label> 
      </div> 

      <div class="loginButton"> 
       <button class="button ion-unlocked button-block button-positive" ng-click="login();" > 
        Login 
       </button> 
      </div> 
     </div> 
    </div> 

    </ion-content> 
</ion-view> 
+0

使用[自动完成(http://www.w3schools.com/tags/att_input_autocomplete.asp)属性:的

可能的复制。 –

+0

@RohitKishore我已经使用过了 –

回答

0

您可以尝试使用jQuery这样的:

<script> 
$(document).ready(function(){ 
$('form').each(function() { 
this.reset() 
}); 
}); 
<script> 
0

如果您在使用jQuery使用此:

您可以重置您的形式 - $("#myform")[0].reset();

$('#form-id').children('input').val('') 

如果您使用的是JavaScript:

<input type="button" value="Submit" id="btnsubmit" onclick="submitForm()"> 

function submitForm() { 
    // Get the first form with the name 
    // Hopefully there is only one, but there are more, select the correct index 
    var frm = document.getElementsByName('contact-form')[0]; 
    frm.submit(); // Submit 
    frm.reset(); // Reset 
    return false; // Prevent page refresh 
} 

希望它有帮助。 How do i clear the previous text field value after submitting the form with out refreshing the entire page