Commit 5bc64ee3 by Alto

Добавил форматирование суммы

1 parent 8a995070
......@@ -105,11 +105,11 @@ $(document).ready(
function fenix_check(el_input)
{
if ($(el_input).length==0)
el_input = $('.fenix_calc input[type="number"][min][max]');
el_input = $('.fenix_calc input[type="number"][min][max], .fenix_calc input[type="text"][min][max]');
$(el_input).each(
function ()
{
var inp_val = $(this).val();
var inp_val = ($(this).val()).split(' ').join('');
var inp_val_int = inp_val|0;
var inp_min = $(this).attr('min')|0;
var inp_max = $(this).attr('max')|0;
......@@ -119,13 +119,20 @@ $(document).ready(
inp_val_int=inp_min;
if (inp_val_int>inp_max)
inp_val_int=inp_max;
if ((inp_val).toString() != (inp_val_int).toString())
$(this).val(inp_val_int);
if ($(this).attr('type')==='number')
{
if ((inp_val).toString() != (inp_val_int).toString())
$(this).val(inp_val_int);
}
else if ((inp_val).toString() != (inp_val_int).toLocaleString())
$(this).val((inp_val_int).toLocaleString());
if ((inp_range).toString() != (inp_val_int).toString())
$(inp_range).val(inp_val_int);
}
);
$('.fenix_calc .calc_btn').toggleClass('disabled', $('.fenix_calc input[type="number"][min][max]:invalid').length>0);
$('.fenix_calc .calc_btn').toggleClass('disabled', $('.fenix_calc input[type="number"][min][max]:invalid, .fenix_calc input[type="text"][min][max]:invalid').length>0);
}
function fenix_calc (el_wrap)
......@@ -247,7 +254,7 @@ $(document).ready(
'change.fenix',
'blur.fenix'
].join(' '),
'.fenix_calc input[type="number"][min][max]',
'.fenix_calc input[type="number"][min][max], .fenix_calc input[type="text"][min][max]',
function ()
{
fenix_check(this);
......@@ -257,7 +264,7 @@ $(document).ready(
'.fenix_calc input[type="range"][min][max]',
function ()
{
$(this).prev('input[type="number"][min][max]').val($(this).val());
$(this).prev('input[type="number"][min][max], input[type="text"][min][max]').val($(this).val());
}
);
}
......
......@@ -19,12 +19,12 @@ function fenix_calc ($atts, $content)
'<div class="col-12 col-md-3">'.
'<div class="mb-3 d-none">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Поступление кредита, руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_credit_'.$atts['id'].'" name="calc_credit" required="required" value="0" min="0" max="10000000" />'.
'<input type="text" class="form-control rounded-pill p-2 px-4" id="calc_credit_'.$atts['id'].'" name="calc_credit" required="required" value="0" min="0" max="10000000" oninput="this.value = this.value.replace(/[^0-9.]/g, \'\').replace(/(\..*?)\..*/g, \'$1\').replace(/^0[^.]/, \'0\');" />'.
'<input type="range" class="form-range d-md-none" min="0" max="10000000" step="1000" id="calc_credit_range_'.$atts['id'].'" />'.
'</div>'.
'<div class="mb-3">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Инвестиции в проект, тыс. руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="" min="10000000" max="250000000" />'.
'<input type="text" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="" min="10000000" max="250000000" oninput="this.value = this.value.replace(/[^0-9.]/g, \'\').replace(/(\..*?)\..*/g, \'$1\').replace(/^0[^.]/, \'0\');" />'.
'<input type="range" class="form-range d-md-none" min="10000000" max="250000000" step="1000" id="calc_inv_range_'.$atts['id'].'" />'.
'</div>'.
'<div class="mb-3">'.
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!