-1

i did research about textbox masking but its all complicated. Is there an easy way to put a comma and .00 in a textbox?

Here's my code

<tbody id="tbody_addIa_ow">
    <tr>
    <td>1</td>
    <td>
   <input required type="text" disabled name="owner_kind_ia[]"  class="form-control char_only limit" />
    </td>
    <td>
  <input required type="text" disabled name="owner_area_ia[]"  class="form-control num_only limit" />
  </td>
  <td>
  <input required type="text" disabled id="txtNum" name="owner_value_ia[]"  class="form-control num_only ia_val limit" />
  </td>
  <td></td>
 </tr>
 </tbody>

i want to put a comma and .00 in owner_value_ia[] while typing.

Thanks in advance

Alex
  • 9,215
  • 8
  • 39
  • 82
Yettt
  • 21
  • 1
  • 10
  • if by "Is there an easy way to put a comma and .00 in a textbox?" you mean: "is there a native way of doing this?" then no. – Alex Jul 24 '18 at 03:25
  • Got it. i put $('.ia_val').mask("#,##0.00", {reverse: true}); in javascript and jquery.mask.min.js – Yettt Jul 24 '18 at 03:28
  • The question seems to be about js/jquery more so than PHP/codeigniter. – user3783243 Jul 24 '18 at 03:35
  • Are you okay with using plugin ? – Vinay Jul 24 '18 at 03:40
  • uhm, yea? now my problem is, its not totaling the 2 value because it has comma. – Yettt Jul 24 '18 at 04:05
  • i think you can use span at the and of input , and by using after psedo element give content ', .00' or whaterver you want and play with span after's position Ref :https://stackoverflow.com/questions/2587669/can-i-use-a-before-or-after-pseudo-element-on-an-input-field – Abhishek Kumar Jul 24 '18 at 04:46

1 Answers1

0

Try this, but this content of yours will be static and if want dynamic, you can change content value using attr(), see that for reference......

input[name='owner_area_ia[]'] + span:after {
  height : 50px;
  width : 50px;
  content : ', .00';
  position : relative;
  left : -50px;
  color : darkgray;
}
<tbody id="tbody_addIa_ow">
    <tr>
    <td>1</td>
    <td>
   <input required type="text" disabled name="owner_kind_ia[]"  class="form-control char_only limit" />
    </td>
    <td>
  <input required type="text" disabled name="owner_area_ia[]"  class="form-control num_only limit" />
      <span></span>
  </td>
  <td>
  <input required type="text" disabled id="txtNum" name="owner_value_ia[]"  class="form-control num_only ia_val limit" />
  </td>
  <td></td>
 </tr>
 </tbody>
Abhishek Kumar
  • 2,501
  • 10
  • 25