I have a input for entering money, also there is a switcher for dollar($) and euro(€) sign. I want to make it, after the user enters a number automatically add dollar and euro sign in order to switcher.
$(document).ready(function(){
$('#myonoffswitch').click(function(){
if($(this).is(":checked")){
$("#1").change(function() {
if (this.value.indexOf("$") === -1) {
this.value = this.value + ",00 $" ;
}
});
}
else{
$("#1").change(function() {
if (this.value.indexOf("€") === -1) {
this.value = this.value + ",00 €" ;
}
});
}
});
});
but the problem is, after checked the switcher two times, output looks like the example below: 1st check: "2,00$" 2nd check: "2,00 $ ,00 €"
how can i remove the dollar sign when 2nd check.
EDIT: my html is looks like this;
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" >
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<div class="inputs">
<input type="text" placeholder="Enter Here" name="1" id="1" autocomplete="off" class="inputName" />
</div>