I use Robin Herbot inputmask plugin for currency inputs. I want to change the currency symbol each time when the exchange dropdown change event triggers. But the inputmask prefix prevents to change the currency symbol. I have this code:
HTML:
@Html.DropDownListFor(model => model.exchange,
new SelectList(@ViewBag.rates, "Value", "Text",4), null, new
{
@Style = "height:34px;width:370px !important;font-size: 14px;",
@class = "form-control input-lg"
}
)
<input type="text"
class="form-control text-left monerate"
id="price1"
name="price1"
placeholder="₺ 0.00"
data-inputmask="'alias': 'numeric', 'groupSeparator': ',', 'autoGroup': true, 'digits': 2, 'digitsOptional': false, 'prefix': '₺ ', 'placeholder': '0'" />
JQuery:
$('input.monerate').inputmask();
$(document.body).delegate('#exchange', 'change', function () {
exchangeID = $('#exchange :selected').val();
if (exchangeID == 1) {
$("#price1").inputmask({ alias: "currency", prefix: '$ ' });
}
else if (exchangeID == 2) {
$("#price1").inputmask({ alias: "currency", prefix: '€ ' });
}
else if (exchangeID == 3) {
$("#price1").inputmask({ alias: "currency", prefix: '£ ' });
}
else if (exchangeID == 4) {
$("#price1").inputmask({ alias: "currency", prefix: '₺ ' });
}
});
Are there a way to change the prefix?
I've read this answer but did not work for me:
Change the currency symbol or remove it in the inputmask currency