Blackjack
Blackjack

Reputation: 1065

How to set punctuation in Yii2 form text field?

I've a form in my Yii2 application. I'm using Kartik\form\activeFor. This is a little view of my form enter image description here

And this is the code

'jumlahBruto' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nilai Total Bruto...'];

How do I can set the data in text field has a dot like this enter image description here

Thanks.

Upvotes: 0

Views: 142

Answers (1)

Rahul
Rahul

Reputation: 18557

Here is your code for masking

jQuery(function($) {
  $("#date").mask("99.999.999");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<input id="date" type="text">

This will solve your problem.

EDIT

As mentioned in documentation, in modal dom is already not loaded.
You need to explicitely call input mask for dynamically loaded elements.

$(":input").inputmask(); $(document).on("ajaxComplete", function(e){ 
   $(":input").inputmask(); 
});

as per author of inputmask here is the link.

Upvotes: 3

Related Questions