我想打破文本框的价值

I want to break textbox value

我正在使用 javascript 添加两个文本框值并将该值存储在同一个文本框中。对于该过程,我正在使用 onmouseenter 事件。当我在那个文本框中输入鼠标时,文本框的值每次都会增加,但我需要避免它。我在这里发布了我的代码,你能解决吗,

function removeFormField() {          
        var count_id = document.getElementById("balance").value;  
        document.getElementById('balance').value = parseInt(count_id)+10;   
}

HTML代码:

<div class="form-group">
     <label for="firstname" class="col-sm-4 control-label">Balance amount</label> 
        <div class="col-sm-6"> 
            <input type="text" class="form-control" id="balance" name="balance" placeholder="Balance amount" onmouseenter="removeFormField();"> 
        </div> 
</div> 

使用标记来跟踪变化

var allowChange = true;
function removeFormField() {          
    if(allowChange){
        var count_id = document.getElementById("balance").value;  
        document.getElementById('balance').value = parseInt(count_id)+10;
        allowChange = false;
    }   
}
<input type="text" class="form-control" id="balance" name="balance" placeholder="Balance amount" onkeypress="removeFormField()"> 

仅对输入事件进行了一项更改。更改为按键,仅在您进入并输入字段时调用。而不是当您在字段上单击鼠标时。